Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 234
dascandy Avatar asked May 25 '11 15:05

dascandy


1 Answers

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

-nopad
    disable standard block padding
like image 172
PhilR Avatar answered Nov 15 '22 06:11

PhilR