Verified Commit c18bf2b8 authored by Marek Behun's avatar Marek Behun Committed by Vojtech Myslivec

Add initial sign script

parent c657cc34
from sys import argv
from hashlib import sha512
from binascii import hexlify
from struct import pack, unpack
def change_endian(s):
res = b''
for i in range(0, len(s), 4):
res += pack(">I", unpack("<I", s[i:i+4])[0])
return res
path = "/sys/devices/platform/soc/soc:internal-regs@d0000000/soc:internal-regs@d0000000:crypto@0/"
pubkey_path = path + "mox_pubkey"
sign_path = path + "mox_do_sign"
pubkey = open(pubkey_path).read()
if pubkey == "none\n":
print("no public key burned")
print("MOX burned public key: %s" % (pubkey,))
if len(argv) < 2:
print("message not given")
print("message: %s" % (argv[1],))
h = sha512()
dig = h.digest()
print("message hash: %s" % (h.hexdigest(),))
s = open(sign_path, "wb")
s = open(sign_path, "rb")
sig =
sig = change_endian(sig)
print("signature: %s" % (hexlify(sig[2:68] + sig[70:]).decode("ascii"),))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment