Monday, April 16, 2012

Linux AES Encryption C

This is an example of AES encryption on Linux with c using openssl apis. I needed this for a project i'm working on and I thought to share this. There are 4 functions, a encrypt/decrypt pair for data stored in memory and one for files.


It's on pastebin

The key and iv, should be obtained differently, I intend to use random 16 bytes keys and ivs, so it's not a problem for me, but if you use it for user entered passwords (key and or iv) you should take a look at EVP_BytesToKey().

Feedback is apreciated.

No comments:

Post a Comment

I reserve the right to delete at any time any comment I deem inappropiate.