From b74005d10a8a1036806b94e88d96e636caf1a76e Mon Sep 17 00:00:00 2001 From: Riccardo Date: Wed, 25 Sep 2019 16:41:38 -0700 Subject: [PATCH] fix sign.py --- crypto/sign.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crypto/sign.py b/crypto/sign.py index b0093e9b99c1e2..6236739513ee0e 100755 --- a/crypto/sign.py +++ b/crypto/sign.py @@ -4,6 +4,7 @@ import struct import hashlib from Crypto.PublicKey import RSA +import binascii rsa = RSA.importKey(open(sys.argv[3]).read()) @@ -20,10 +21,11 @@ else: x = dat dd = hashlib.sha1(dat).digest() - print("hash:",dd.encode("hex")) - dd = "\x00\x01" + "\xff"*0x69 + "\x00" + dd - rsa_out = pow(int(dd.encode("hex"), 16), rsa.d, rsa.n) - sig = (hex(rsa_out)[2:-1].rjust(0x100, '0')).decode("hex") - x += sig + + print("hash:", binascii.hexlify(dd)) + dd = b"\x00\x01" + b"\xff"*0x69 + b"\x00" + dd + rsa_out = pow(int.from_bytes(dd, byteorder='big', signed=False), rsa.d, rsa.n) + sig = (hex(rsa_out)[2:].rjust(0x100, '0')) + x += binascii.unhexlify(sig) f.write(x)