mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-10 05:59:08 -07:00
FindMy: Fix key generation script
This commit is contained in:
@@ -23,11 +23,16 @@ def convert_key_to_hex(private_key, public_key):
|
|||||||
return private_key_hex, public_key_hex
|
return private_key_hex, public_key_hex
|
||||||
|
|
||||||
def generate_mac_and_payload(public_key):
|
def generate_mac_and_payload(public_key):
|
||||||
public_key_bytes = public_key.public_numbers().x.to_bytes(28, byteorder='big')
|
key = public_key.public_numbers().x.to_bytes(28, byteorder='big')
|
||||||
mac = public_key_bytes[:6].hex()
|
|
||||||
payload = advertisement_template()
|
addr = bytearray(key[:6])
|
||||||
payload[7:29] = public_key_bytes[6:22]
|
addr[0] |= 0b11000000
|
||||||
return mac, payload.hex()
|
|
||||||
|
adv = advertisement_template()
|
||||||
|
adv[7:29] = key[6:28]
|
||||||
|
adv[29] = key[0] >> 6
|
||||||
|
|
||||||
|
return addr.hex(), adv.hex()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
nkeys = int(input('Enter the number of keys to generate: '))
|
nkeys = int(input('Enter the number of keys to generate: '))
|
||||||
@@ -57,14 +62,14 @@ def main():
|
|||||||
|
|
||||||
if '/' not in s256_b64[:7]:
|
if '/' not in s256_b64[:7]:
|
||||||
fname = f"{prefix}_{s256_b64[:7]}.keys" if prefix else f"{s256_b64[:7]}.keys"
|
fname = f"{prefix}_{s256_b64[:7]}.keys" if prefix else f"{s256_b64[:7]}.keys"
|
||||||
|
|
||||||
print(f'{i + 1})')
|
print(f'{i + 1})')
|
||||||
print('Private key (Base64):', private_key_b64)
|
print('Private key (Base64):', private_key_b64)
|
||||||
print('Public key (Base64):', public_key_b64)
|
print('Public key (Base64):', public_key_b64)
|
||||||
print('Hashed adv key (Base64):', s256_b64)
|
print('Hashed adv key (Base64):', s256_b64)
|
||||||
print('---------------------------------------------------------------------------------')
|
print('---------------------------------------------------------------------------------')
|
||||||
print('Private key (Hex):', private_key_hex)
|
print('Private key (Hex):', private_key_hex)
|
||||||
print('Public key (Hex):', public_key_hex)
|
print('Public key (Hex):', public_key_hex)
|
||||||
print('---------------------------------------------------------------------------------')
|
print('---------------------------------------------------------------------------------')
|
||||||
print('MAC:', mac)
|
print('MAC:', mac)
|
||||||
print('Payload:', payload)
|
print('Payload:', payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user