Print message for unknown sig.

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-04-21 23:53:04 +03:00
parent 9738da7dca
commit 30069c3d2b
Signed by: Hesham
GPG Key ID: 74876157D199B09E

7
rsa.py
View File

@ -74,7 +74,10 @@ 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]))
print("Signed by: ", sig) if sig == None:
print("Unknown signature!")
else:
print("Signed by: ", sig)
print("Decrypted message: \n", msg_decrypted) print("Decrypted message: \n", msg_decrypted)
else: else:
print("Not enough arguments") print("Not enough arguments")
@ -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()