mtkclient/Tools/rpmb_test.py

26 lines
1.6 KiB
Python
Raw Permalink Normal View History

2023-06-11 13:35:12 -04:00
#!/usr/bin/env python3
import hashlib
import hmac
2023-12-29 16:12:09 -05:00
rpmbframe = bytearray(bytes.fromhex(
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +
'00000000000000000000000000000000000000000000000000000000776385c27c171e97c52a7ed8d22a6739b285ea4676d258f178802c5a' +
'e2290a3200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +
'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c' +
'0000000000000200'))
2023-06-11 13:35:12 -04:00
"""
xflashext - RPMB : 899cd7692b4777042c094476920f6b1bf88b303abca5e0e14464e034551a1f52
"""
2023-12-29 16:12:09 -05:00
rpmbkey_dxcc = bytes.fromhex('899cd7692b4777042c094476920f6b1bf88b303abca5e0e14464e034551a1f52')
2023-06-11 13:35:12 -04:00
for rpmbkey in [rpmbkey_dxcc]:
2023-12-29 16:12:09 -05:00
# rpmbkey=rpmbkey[::-1]
res = hmac.new(key=rpmbkey, msg=rpmbframe[0xE4:0xE4 + 284], digestmod=hashlib.sha256).digest()
if res == rpmbframe[0xC4:0xE4]:
2023-06-11 13:35:12 -04:00
print("RPMB Key is valid !")