0

I have a 16 byte file, and after encrypting it, its size weirdly changes.

> hexdump -C 1.txt
00000000  61 61 61 61 61 61 61 61  61 61 61 61 61 61 61     |aaaaaaaaaaaaaaa|
0000000f
> openssl enc -v -aes-128-ecb -nosalt -base64 -in 1.txt -out 2.txt

...

bytes read:    16
bytes written: 45

It becomes 45 bytes.

  • Why is it not a multiple of 16, since AES has 16-byte blocks?
  • If openssl adds a header of some sort, how large is it, and is it fixed size? I can't find any thing in the documentation that mentions this.
Donald
  • 693
  • 1
  • 7
  • 12
  • Although your `hexdump` claims 15 bytes, your file apparently is actually 16 bytes. ECB requires padding to the _next_ multiple of the blocksize, so for AES the ciphertext is 32 bytes. You specified encoding in base64, and the base64 encoding of 32 bytes is ceil(32/3)*4=44 characters plus one newline character makes 45. PS: `enc` _normally_ uses password-based encryption with salt, and writes a 16 byte header containing the salt, but not when you specify `-nosalt` – dave_thompson_085 Feb 13 '20 at 08:26
  • Apparently reasked at https://crypto.stackexchange.com/questions/77582/openssl-not-producing-messages-of-expected-size and answered – dave_thompson_085 Feb 14 '20 at 01:47

0 Answers0