-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverifyRSA.py
49 lines (26 loc) · 854 Bytes
/
verifyRSA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import fileOp
import fdh
class verifier:
def __init__(self):
try:
self.signature = fileOp.read_list_noint("Fsignature")[0]
except:
raise Exception("Failed to read Fsignature")
self.verify()
self.verify(fname)
def verify(self,fname):
ciphertext = fileOp.read_list("Fciphertext")[0]
n = fileOp.read_list("FpublicKey")[0]
public_key = fileOp.read_list("FpublicKey")[1]
inp = fname
inp = fileOp.read_binary_file(inp)
inp = fdh.fdh(inp,(len(bin(n))-2))
signaturec = pow(ciphertext,public_key,n)
if signaturec - int(inp,16) == 0:
print("VERIFIED!")
return True
else:
print("FAILED!")
return False
if __name__ == "__main__":
v = verifier("picn.jpg")