diff options
author | Ben Laurie <ben@openssl.org> | 2008-12-29 16:11:58 +0000 |
---|---|---|
committer | Ben Laurie <ben@openssl.org> | 2008-12-29 16:11:58 +0000 |
commit | 0eab41fb78cf4d7c76e563fd677ab6c32fc28bb0 (patch) | |
tree | da848c7424ced86fc60823f4948b0fc79e52a381 /crypto/evp/p5_crpt.c | |
parent | 8aa02e97a782a4229936d5df6da42db3efe4acd1 (diff) |
If we're going to return errors (no matter how stupid), then we should
test for them!
Diffstat (limited to 'crypto/evp/p5_crpt.c')
-rw-r--r-- | crypto/evp/p5_crpt.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/evp/p5_crpt.c b/crypto/evp/p5_crpt.c index 9c6e07b706..7ecfa8dad9 100644 --- a/crypto/evp/p5_crpt.c +++ b/crypto/evp/p5_crpt.c @@ -81,6 +81,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, int saltlen, iter; unsigned char *salt; const unsigned char *pbuf; + int mdsize; /* Extract useful info from parameter */ if (param == NULL || param->type != V_ASN1_SEQUENCE || @@ -109,9 +110,12 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, EVP_DigestUpdate(&ctx, salt, saltlen); PBEPARAM_free(pbe); EVP_DigestFinal_ex(&ctx, md_tmp, NULL); + mdsize = EVP_MD_size(md); + if (mdsize < 0) + return 0; for (i = 1; i < iter; i++) { EVP_DigestInit_ex(&ctx, md, NULL); - EVP_DigestUpdate(&ctx, md_tmp, EVP_MD_size(md)); + EVP_DigestUpdate(&ctx, md_tmp, mdsize); EVP_DigestFinal_ex (&ctx, md_tmp, NULL); } EVP_MD_CTX_cleanup(&ctx); |