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