Print message for unknown sig.
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
9738da7dca
commit
30069c3d2b
5
rsa.py
5
rsa.py
@ -74,6 +74,9 @@ def main():
|
|||||||
key = readKeyFile(sys.argv[3])
|
key = readKeyFile(sys.argv[3])
|
||||||
for cipher_word in cipher_list:
|
for cipher_word in cipher_list:
|
||||||
msg_decrypted = msg_decrypted + " " + str(decrypt(int(cipher_word, 16),key[D],key[N]))
|
msg_decrypted = msg_decrypted + " " + str(decrypt(int(cipher_word, 16),key[D],key[N]))
|
||||||
|
if sig == None:
|
||||||
|
print("Unknown signature!")
|
||||||
|
else:
|
||||||
print("Signed by: ", sig)
|
print("Signed by: ", sig)
|
||||||
print("Decrypted message: \n", msg_decrypted)
|
print("Decrypted message: \n", msg_decrypted)
|
||||||
else:
|
else:
|
||||||
@ -201,12 +204,14 @@ def verify(cipher_list):
|
|||||||
cipher_list.reverse() #To get last word using index 0
|
cipher_list.reverse() #To get last word using index 0
|
||||||
encrypted_sig = cipher_list[0]
|
encrypted_sig = cipher_list[0]
|
||||||
cipher_list.reverse()
|
cipher_list.reverse()
|
||||||
|
sig = None
|
||||||
for key_name in local_keys:
|
for key_name in local_keys:
|
||||||
key = readKeyFile(key_name)
|
key = readKeyFile(key_name)
|
||||||
print("Found key: ", key_name)
|
print("Found key: ", key_name)
|
||||||
sig = str(decrypt(int(encrypted_sig, 16), key[E], key[N]))
|
sig = str(decrypt(int(encrypted_sig, 16), key[E], key[N]))
|
||||||
if "sig:" in sig:
|
if "sig:" in sig:
|
||||||
return sig.replace("sig:","")
|
return sig.replace("sig:","")
|
||||||
|
else: return sig
|
||||||
|
|
||||||
def readKeyFile(keyName):
|
def readKeyFile(keyName):
|
||||||
key = tuple()
|
key = tuple()
|
||||||
|
Loading…
Reference in New Issue
Block a user