user296589 user296589 - 1 year ago 86
C++ Question

Encrypt with AES without header

I'm trying to encrypt a 16KiB block with AES.

I tried to do it with openssl, but the size grew from 16384 to 16416. Looks like openssl put a 32B header.

Is there any way to "remove" the 32B header? If it matters, my environment is Redhat 5.11.

I tried only the command line tools of openssl:

openssl aes-256-cbc -in text.txt -out encrypted.txt


openssl aes-256-cbc -d -in encrypted.txt -out decrypted.txt

Also - I need a tool that I can use with C++.

Answer Source

No, it did not put a header. It did padding.

The AES is a block cipher with 128 bit block size that requires the length of data being enciphered to be even to the cipher block size. This padding is also used to recover the original data stream length after deciphering.


According to @jww the openssl lib also prepends the stream with 16byte header containing a magic 8-byte string "Salted__" and and an IV, derived from the password

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download