diff options
author | Dr. Stephen Henson <steve@openssl.org> | 1999-07-30 10:11:21 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 1999-07-30 10:11:21 +0000 |
commit | 08dbdb85eeb860f5a74a7d04efc3ed56372d372a (patch) | |
tree | 0d8ef958944bf3af06a138c660a3ed74fd18db23 /crypto/pkcs12 | |
parent | 922180d794873b3aa6fac3412a73c829b1dbd27c (diff) |
Fix to PKCS#12 code to use the cipher block length when allocating a buffer
for encrypted data, rather than hard coding '8'.
Diffstat (limited to 'crypto/pkcs12')
-rw-r--r-- | crypto/pkcs12/p12_decr.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crypto/pkcs12/p12_decr.c b/crypto/pkcs12/p12_decr.c index 8f502fae7f..d3d288e187 100644 --- a/crypto/pkcs12/p12_decr.c +++ b/crypto/pkcs12/p12_decr.c @@ -76,17 +76,18 @@ unsigned char * PKCS12_pbe_crypt (X509_ALGOR *algor, const char *pass, int outlen, i; EVP_CIPHER_CTX ctx; - if(!(out = Malloc (inlen + 8))) { - PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_MALLOC_FAILURE); - return NULL; - } - /* Decrypt data */ if (!EVP_PBE_CipherInit (algor->algorithm, pass, passlen, algor->parameter, &ctx, en_de)) { PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR); return NULL; } + + if(!(out = Malloc (inlen + EVP_CIPHER_CTX_block_size(&ctx)))) { + PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_MALLOC_FAILURE); + return NULL; + } + EVP_CipherUpdate (&ctx, out, &i, in, inlen); outlen = i; if(!EVP_CipherFinal (&ctx, out + i, &i)) { |