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.
Refs:
http://www.openssl.org/docs/crypto/EVP_EncryptInit.html#
http://saju.net.in/blog/?p=36
It's on pastebin
http://pastebin.com/GFdTB2Yc
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
I reserve the right to delete at any time any comment I deem inappropiate.