Derive B-Keys as well

Small nit: rename "master" to "salt".

Fixes #4.
This commit is contained in:
Queen Vinyl Da.i'gyu-Kazotetsu committed 2025-12-31 03:44:00 -08:00
1 parent 3ad3fcfdbf
commit 088e33b7c8
1 file changed
+3 -2
+3 -2
View File
@@ -3,6 +3,7 @@
# Python script to generate keys for Bambu Lab RFID tags
# Created for https://github.com/Bambu-Research-Group/RFID-Tag-Guide
# Written by thekakester (https://github.com/thekakester) and Vinyl Da.i'gyu-Kazotetsu (www.queengoob.org), 2024
# Requires: pycryptodomex
import sys
from Cryptodome.Protocol.KDF import HKDF
@@ -13,8 +14,8 @@ if not sys.version_info >= (3, 6):
exit(-1)
def kdf(uid):
master = bytes([0x9a,0x75,0x9c,0xf2,0xc4,0xf7,0xca,0xff,0x22,0x2c,0xb9,0x76,0x9b,0x41,0xbc,0x96])
return HKDF(uid, 6, master, SHA256, 16, context=b"RFID-A\0")
salt = bytes([0x9a,0x75,0x9c,0xf2,0xc4,0xf7,0xca,0xff,0x22,0x2c,0xb9,0x76,0x9b,0x41,0xbc,0x96])
return HKDF(uid, 6, salt, SHA256, 16, context=b"RFID-A\0") + HKDF(uid, 6, salt, SHA256, 16, context=b"RFID-B\0")
if __name__ == '__main__':
uid = bytes.fromhex(sys.argv[1])