A typical method is to use PKCS#7 padding.

On 12/12/2012 9:07 AM, Hailei Hu wrote:
Hi, everyone!
     I am testing openssl AES encrypt and decrypt using AES_cbc_encrypt.
     for example, I have a file which has 10 bytes, after using
AES_cbc_encrypt, the encrypted file become 16 bytes. But when I use
anohter program to decrypt this encrypted file using AES_cbc_encrypt,
How could I know the correct decrypted file size? Because according to
the declaration of AES_cbc_encrypt:

void AES_cbc_encrypt
(const unsigned char *in,
unsigned char *out,
const unsigned long length,
const AES_KEY *key, /* it will be changed during the encrypt&decrypt
process, so it required to be reset each time */
unsigned char *ivec, /* salt, it will be changed during the
encrypt&decrypt process, so it required to be reset each time */
const int enc /*AES_ENCRYPT for encrypt and other values for descrypt*/
);

when I call this function, param "length" is the encrypted file size.
But I think the decrypted  file size should be less than "param length".
So How could I know how many bytes I should read from "out" to write to
a decrypted file ?


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to