import os.path import sys fileutils = FileUtils() rsatools = RSAtools() #Making sure the arguments and the files are there clientkey_file = open(sys.argv[2], 'r') merchantkey_file = open(sys.argv[3], 'r') #Getting client's key and merchant's original key clientkey_original = fileutils.recupKey(sys.argv[2]) merchant_key_original = fileutils.recupKey(sys.argv[3]) #Getting client's key ciphered by the bank and bank's private key clientkeybanqueciphered = [] clientkeybanqueciphered.append(fileutils.readKey(sys.argv[1],2)) clientkeybanqueciphered.append(fileutils.readKey(sys.argv[1],3)) bank_publickey = fileutils.recupKey('banquePk') #Deciphering the client's key clientkey_deciphered = [rsatools.decryptblock(bank_publickey, clientkeybanqueciphered[0]), rsatools.decryptblock(bank_publickey, clientkeybanqueciphered[1])] #Verification if( clientkey_deciphered != clientkey_original): print("La clé du client dans le chèque n'est pas la même que celle fournie !\n") #Getting merchant's key ciphered by the client and deciphering it merchantkeyclientciphered = [] merchantkeyclientciphered.append( fileutils.readKey(sys.argv[1],0)) merchantkeyclientciphered.append( fileutils.readKey(sys.argv[1],1))
print("Error reading file : ", error) sys.exit() fileutils = FileUtils() rsatools = RSAtools() #Getting the infos from the files clepub_client = fileutils.recupKey(sys.argv[3]) facture = Facture(sys.argv[1]) clepub_merchant_original = fileutils.recupKey("commercantPk") bankPk = fileutils.recupKey("banquePk") merchantkeyclientciphered = [] clientkeybanqueciphered = [] merchantkeyclientciphered.append( fileutils.readKey(sys.argv[2],0)) merchantkeyclientciphered.append( fileutils.readKey(sys.argv[2],1)) clientkeybanqueciphered.append(fileutils.readKey(sys.argv[2],2)) clientkeybanqueciphered.append(fileutils.readKey(sys.argv[2],3)) uid_ciphered = fileutils.readKey(sys.argv[2],4) sum_ciphered = fileutils.readKey(sys.argv[2],5) clepub_client = [rsatools.decryptblock(bankPk, clientkeybanqueciphered[0]), rsatools.decryptblock(bankPk, clientkeybanqueciphered[1])] clepub_merchant = [rsatools.decryptblock( clepub_client, merchantkeyclientciphered[0]), rsatools.decryptblock( clepub_client, merchantkeyclientciphered[1])] #Decyphering the cypher of the sum and of the id by the client uid_clear = rsatools.decryptblock(clepub_client, uid_ciphered) sum_clear = rsatools.decryptblock(clepub_client, sum_ciphered)