crypto++ - Encrypt/Decrypt with AES -
I am writing a small program to encrypt / decrypt using AES. I'm using the crypt library.
I need help to understand some things.
When I am encrypting the file, should I write IV at the beginning of the file to decrypt it later? / P>
I did not want to correct the password given to the decrypt file. I want to:
-
Before encrypting, put some strings at the beginning of the file (e.g., TRUE) check it after decryption.
-
Check the MD5 of the file before encryption. Keep it at the beginning of the encrypted file Read MD5 before decryption, check decrypt file, MD5 of decrypted file and compare them.
Writing IV in the beginning of the file is OK. Adding to the end is another option.
Do not put a static string in plain text: For very similar reasons, the tape was broken very easily, and for this common mistake a cruel password is made.
The MD5 approach looks satisfactory; But HMAC-SHA 256 will provide quite strong integrity claims. (I think you can reuse IV for AES key or HMCAC-SAS 256, but I'm not positive about its security.)
Comments
Post a Comment