diff options
author | Richard Levitte <levitte@openssl.org> | 2015-11-27 14:17:50 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2015-12-07 17:36:57 +0100 |
commit | 77a01145be26ceeefa6870e1e9dd7f99ac123fa3 (patch) | |
tree | 5b2426456e3a7f4b8fd4790462ebf7068b547622 /crypto/evp/p5_crpt.c | |
parent | 7638370ca6cb1d89eba5d891f522776b9da3d6e7 (diff) | |
download | openssl-77a01145be26ceeefa6870e1e9dd7f99ac123fa3.zip openssl-77a01145be26ceeefa6870e1e9dd7f99ac123fa3.tar.gz openssl-77a01145be26ceeefa6870e1e9dd7f99ac123fa3.tar.bz2 |
Have other crypto/evp files include evp_locl.h
Note: this does not include the files in crypto/evp that are just
instanciations of EVP_MD.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/evp/p5_crpt.c')
-rw-r--r-- | crypto/evp/p5_crpt.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/crypto/evp/p5_crpt.c b/crypto/evp/p5_crpt.c index 2d37d08..26bf048 100644 --- a/crypto/evp/p5_crpt.c +++ b/crypto/evp/p5_crpt.c @@ -75,7 +75,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de) { - EVP_MD_CTX ctx; + EVP_MD_CTX *ctx; unsigned char md_tmp[EVP_MAX_MD_SIZE]; unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; int i; @@ -84,7 +84,6 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, unsigned char *salt; int mdsize; int rv = 0; - EVP_MD_CTX_init(&ctx); /* Extract useful info from parameter */ if (param == NULL || param->type != V_ASN1_SEQUENCE || @@ -111,24 +110,30 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, else if (passlen == -1) passlen = strlen(pass); - if (!EVP_DigestInit_ex(&ctx, md, NULL)) + ctx = EVP_MD_CTX_create(); + if (ctx == NULL) { + EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, ERR_R_MALLOC_FAILURE); goto err; - if (!EVP_DigestUpdate(&ctx, pass, passlen)) + } + + if (!EVP_DigestInit_ex(ctx, md, NULL)) + goto err; + if (!EVP_DigestUpdate(ctx, pass, passlen)) goto err; - if (!EVP_DigestUpdate(&ctx, salt, saltlen)) + if (!EVP_DigestUpdate(ctx, salt, saltlen)) goto err; PBEPARAM_free(pbe); - if (!EVP_DigestFinal_ex(&ctx, md_tmp, NULL)) + if (!EVP_DigestFinal_ex(ctx, md_tmp, NULL)) goto err; mdsize = EVP_MD_size(md); if (mdsize < 0) return 0; for (i = 1; i < iter; i++) { - if (!EVP_DigestInit_ex(&ctx, md, NULL)) + if (!EVP_DigestInit_ex(ctx, md, NULL)) goto err; - if (!EVP_DigestUpdate(&ctx, md_tmp, mdsize)) + if (!EVP_DigestUpdate(ctx, md_tmp, mdsize)) goto err; - if (!EVP_DigestFinal_ex(&ctx, md_tmp, NULL)) + if (!EVP_DigestFinal_ex(ctx, md_tmp, NULL)) goto err; } OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= (int)sizeof(md_tmp)); @@ -143,6 +148,6 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); rv = 1; err: - EVP_MD_CTX_cleanup(&ctx); + EVP_MD_CTX_destroy(ctx); return rv; } |