views:

402

answers:

1

For some sensitive data I decided to store it AES-encrypted on disc. I've implemented the encryption using PyCrypto.

Furthermore, the data is important, and the stored encrypted data will be my only copy of it (backups aside), so I looked for some means of retrieving the data without using PyCrypto to have a fallback given the possibility that PyCrypto is not longer available to me (for whatever reason that may be).

I thought mcrypt could be an option.

This is my test case to get some ciphertext written:

import Crypto.Cipher.AES
import sys

pwd  = 'qwertzuiopasdfgh'
mode = Crypto.Cipher.AES.MODE_CBC
aes  = Crypto.Cipher.AES.new( pwd, mode )
text = 'asdfghjklyxcvbnm'
sys.stdout.write( aes.encrypt( text ) )

I redirected the output to a file out.nc and tried decryption by

mcrypt -d -b -k qwertzuiopasdfgh -a rijndael-128 -m CBC out.nc

but the resulting file out has zero bytes size, unfortunately.

I hope there is a combination of options to mcrypt to make this work…

A: 

Why is it important to be able to recover without PyCrypto?

But if that is the case, you should probably use something else. You didn't indicate how big the thing is that you want to save. But you might use PGP or OpenSSL or some other widely available encryption system.

vy32
Well, let's assume that PyCrypto is no longer supported by my Linux Distribution, the associated web site is switched off and I can't get the source to compile on my system. Bad situation for my valuable but encrypted data. Additionally, I'd like to verify that my encryption worked as I expected up front. I've seen that there are a good number of combinations to do AES, so I cannot take that for granted. Regarding other solutions: Yes, OpenSSL looks like a decent candidate. I've yet to find a python binding that gives access to the encryption capabilities.
mkluwe
sure. That's why you need to keep a copy of your decryption tool. You don't need a Python fun OpenSSL; you can use the command line interface and Popen.
vy32