summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/p5_crpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/p5_crpt.c')
-rw-r--r--src/lib/libcrypto/evp/p5_crpt.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c
index 48d50014a0..a1874e83b2 100644
--- a/src/lib/libcrypto/evp/p5_crpt.c
+++ b/src/lib/libcrypto/evp/p5_crpt.c
@@ -110,18 +110,12 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
110 int i; 110 int i;
111 PBEPARAM *pbe; 111 PBEPARAM *pbe;
112 int saltlen, iter; 112 int saltlen, iter;
113 unsigned char *salt; 113 unsigned char *salt, *pbuf;
114 const unsigned char *pbuf;
115 114
116 /* Extract useful info from parameter */ 115 /* Extract useful info from parameter */
117 if (param == NULL || param->type != V_ASN1_SEQUENCE ||
118 param->value.sequence == NULL) {
119 EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
120 return 0;
121 }
122
123 pbuf = param->value.sequence->data; 116 pbuf = param->value.sequence->data;
124 if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) { 117 if (!param || (param->type != V_ASN1_SEQUENCE) ||
118 !(pbe = d2i_PBEPARAM (NULL, &pbuf, param->value.sequence->length))) {
125 EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); 119 EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
126 return 0; 120 return 0;
127 } 121 }
@@ -146,7 +140,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
146 EVP_DigestFinal_ex (&ctx, md_tmp, NULL); 140 EVP_DigestFinal_ex (&ctx, md_tmp, NULL);
147 } 141 }
148 EVP_MD_CTX_cleanup(&ctx); 142 EVP_MD_CTX_cleanup(&ctx);
149 OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= (int)sizeof(md_tmp)); 143 OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= sizeof md_tmp);
150 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); 144 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher));
151 OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16); 145 OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16);
152 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), 146 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)),