summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs12/p12_crpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pkcs12/p12_crpt.c')
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crpt.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c
index 003ec7a33e..3ad33c49d8 100644
--- a/src/lib/libcrypto/pkcs12/p12_crpt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crpt.c
@@ -84,19 +84,25 @@ EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC2_CBC, EVP_rc2_40_cbc(),
84#endif 84#endif
85} 85}
86 86
87int PKCS12_PBE_keyivgen (EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 87int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
88 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de) 88 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de)
89{ 89{
90 PBEPARAM *pbe; 90 PBEPARAM *pbe;
91 int saltlen, iter, ret; 91 int saltlen, iter, ret;
92 unsigned char *salt, *pbuf; 92 unsigned char *salt;
93 const unsigned char *pbuf;
93 unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; 94 unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH];
94 95
95 /* Extract useful info from parameter */ 96 /* Extract useful info from parameter */
97 if (param == NULL || param->type != V_ASN1_SEQUENCE ||
98 param->value.sequence == NULL) {
99 PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_DECODE_ERROR);
100 return 0;
101 }
102
96 pbuf = param->value.sequence->data; 103 pbuf = param->value.sequence->data;
97 if (!param || (param->type != V_ASN1_SEQUENCE) || 104 if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) {
98 !(pbe = d2i_PBEPARAM (NULL, &pbuf, param->value.sequence->length))) { 105 PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_DECODE_ERROR);
99 EVPerr(PKCS12_F_PKCS12_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
100 return 0; 106 return 0;
101 } 107 }
102 108