The problem is that aes_cbc is a block cipher and works on 16-byte blocks,
typically.  By default, any data block that is less than this size is
padded, as is the case for you.  Since you're only sending in 10 bytes, your
10 bytes are being padded with zeros to make the block 16 bytes.

So, to answer your question, you can do one of two things.  First, you can
set the length parameter on the decrypt operation to be 16 which will
provide you with a result that is your original 10 bytes plus 6 bytes of
zeros, which you can then remove.  The better approach would be to specify
"no padding" in your structure.  This can be done using the function
EVP_CIPHER_CTX_set_padding.  Set the padding parameter to zero and your
output should always be the same length as your inputs.

Hope that helps.



--
View this message in context: 
http://openssl.6102.n7.nabble.com/openssl-AES-decrypt-problem-tp42667p42668.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to