There are many questions around this topic, but I haven't found one that explains exactly my issue.
I am encrypting data with AES 128 CBC, but using python and pycryptodome
(should have used the python openssl, but couldn't find it) and specifying the key and iv (which is generally random). So, the key is not salted.
When I try using openssl 1.1.0g with ... | openssl enc -aes128 -d -K <key> -iv <initialization vector>
, the operation fails with the 'digital envelope' failure after decrypting most of the string. If I add `-nopad', then it works completely, without error. The output difference is 11 bytes.
The original input is padded with binary 0s to a multiple of 16 bytes before encrypting, the encrypted string is converted to hex, then the hex iv is prepended and everything is base64 encoded.
Can anyone shed any light on why I need the -nopad
option? I thought that with the -K
and -iv
options, openssl wouldn't process the salt at all for the decryption.