diff --git a/README.md b/README.md index ff49420..e879ed6 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,28 @@ OnekeyProBTFW_FACTORY_HEX OnekeyProBTFW_FLASH_FACTORY ``` +## How to verify firmware hash + +Install Python 3.x + +Download latest `ota.bin`, open a terminal in the same folder, invoke python, then run following code + +```python +import struct, hashlib + +with open("ota.bin", mode="br") as f: + f.seek(0x0C) + codelen = struct.unpack("i", f.read(4))[0] - 512 + f.seek(0x600) + print("".join(format(x, "02x") for x in hashlib.sha256(f.read(codelen)).digest())) +``` + +Single line version + +```python +exec("""\nimport struct, hashlib\nwith open("ota.bin", mode="br") as f:\n f.seek(0x0C)\n codelen = struct.unpack("i", f.read(4))[0] - 512\n f.seek(0x600)\n print("".join(format(x, "02x") for x in hashlib.sha256(f.read(codelen)).digest()))\n""") +``` + ## License -Please check License.md for details \ No newline at end of file +Please check License.md for details