I have asked a similar question in post Encrypting a file with RSA in Python , but this question has a different connotation.
I am encrypting a file with AES, using RSA to encrypt the AES password.
The only difference is that i really DON'T want to store the AES password. The user must give both the path to his RSA key, and the password.
So what do you think about this scheme?
path_to_RSA_key = ... # Given by the user pwd = ... # This will be used to encrypt the file. Also given by user. rsa_enc = RSA.importKey(path_to_RSA_key) # Encrypt the Password with RSA, keep the last 32 characters rsa_pwd = rsa_enc.encrypt(pwd)[-32:] # Aes, with the encrypted password aes_enc = AES.new(rsa_pwd, AES.MODE_CBC) # Encrypt the file with AES... # Store only the encrypted file # Don't store the password in any way, don't store the path to RSA key
The alternative would be the classic scheme, when you generate a random password, encrypt the file with AES using the random pass, encrypt the random pwd with RSA and store only the encrypted results.
If you really need to know why i need this, it's a project of mine, http://code.google.com/p/scrambled-egg
What do you think about the scheme ? Thank you in advance !