Skip to content

Commit

Permalink
fix sign.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini committed Sep 25, 2019
1 parent fe72770 commit b74005d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crypto/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import struct
import hashlib
from Crypto.PublicKey import RSA
import binascii

rsa = RSA.importKey(open(sys.argv[3]).read())

Expand All @@ -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)

0 comments on commit b74005d

Please sign in to comment.