mtkclient/Tools/rpmb_test.py
2024-06-29 16:48:59 +02:00

25 lines
1.6 KiB
Python
Executable file

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