Search code examples
bashcryptographyopensslaes

openssl AES encryption adds a blocksize worth of bytes to output


I'm trying to encrypt with openssl on the console to match output generated by another implementation of AES. All details are known. I'm using AES in 128-bit CBC mode. Weirdly enough, irrespective of the file size, the output will be 16 bytes larger. I think openssl is appending some kind of padding.

In the direction to the other implementation it's not that much of a problem as I can drop the last 16 bytes, but the other way around is as I can't invent the bytes that openssl will probably check for validity.

How do I tell openssl not to do that?

Commandline:

openssl enc -aes-128-cbc -K <pre-shared key in hex> -in rawfile.bin -out encfile.enc -iv <pre-shared IV in hex>

Solution

  • openssl enc has a -nopad option. I've not used it, but it sounds relevant.

    -nopad
        disable standard block padding