From 30069c3d2be0e71f8752ab8702e68982994a9199 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 21 Apr 2020 23:53:04 +0300 Subject: [PATCH] Print message for unknown sig. Signed-off-by: HeshamTB --- rsa.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rsa.py b/rsa.py index 4804c5a..78ecb14 100755 --- a/rsa.py +++ b/rsa.py @@ -74,7 +74,10 @@ def main(): key = readKeyFile(sys.argv[3]) for cipher_word in cipher_list: 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) else: print("Not enough arguments") @@ -201,12 +204,14 @@ def verify(cipher_list): cipher_list.reverse() #To get last word using index 0 encrypted_sig = cipher_list[0] cipher_list.reverse() + sig = None for key_name in local_keys: key = readKeyFile(key_name) print("Found key: ", key_name) sig = str(decrypt(int(encrypted_sig, 16), key[E], key[N])) if "sig:" in sig: return sig.replace("sig:","") + else: return sig def readKeyFile(keyName): key = tuple()