Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I'm using pycrypto to encrypt files that will be stored in the cloud. I expect the user to enter a password to decrypt files, but encryption shouldn't require a password (to allow the script to be run by cron). So therefore I've been looking at public key encryption using RSA under the PKCS1_OAEP cipher.

I can see how to encrypt a file using pycrypto, but is there a pre-existing method to perform authenticated encryption, or am I expected to implement that myself? There's a parameter to pass a hashing algorithm to Crypto.Cipher.PKCS1_OAEP.new(), but will this be used to sign encrypted data?

Similarly to verify before decryption, is this all built into the decrypt() method?

Note: I don't have any particular attachment to pycrypto - if another python crypto library provides an authenticated encryption scheme, please suggest that instead.

Thanks

share|improve this question
    
Maybe I'll just switch to python-gnupg: packages.python.org/python-gnupg/… –  Andrew Jan 23 '13 at 16:09

1 Answer 1

up vote 0 down vote accepted

PGP (python-gnupg) really sounds like the way you want to go.

Public key crypto is messy because the actual asymmetric cipher is only used to encrypt a one-time session key, which is then used with symmetric crypto (e.g. AES) to encrypt your files. Managing all of that manually would be a headache. But PGP already has all of the details worked out, you just have to call the appropriate functions.

Plus, you have pre-built CLI tools (gpg) to allow you to work with messages outside your app.

share|improve this answer
    
Do you know whether pycrypto provides authenticated encryption. –  Andrew Jan 24 '13 at 17:27
    
Pycrypto provides access to cryptographic primitives and common algorithms. If you want something specific, you have to know specifically what you want. As in, which algorithm. –  tylerl Jan 24 '13 at 20:13
    
OCB or GCM ideally –  Andrew Jan 25 '13 at 10:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.