summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs12/p12_key.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pkcs12/p12_key.c')
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 9e57eee4a4..a29794bbbc 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -81,15 +81,18 @@ int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
81 int ret; 81 int ret;
82 unsigned char *unipass; 82 unsigned char *unipass;
83 int uniplen; 83 int uniplen;
84
84 if(!pass) { 85 if(!pass) {
85 unipass = NULL; 86 unipass = NULL;
86 uniplen = 0; 87 uniplen = 0;
87 } else if (!asc2uni(pass, passlen, &unipass, &uniplen)) { 88 } else if (!OPENSSL_asc2uni(pass, passlen, &unipass, &uniplen)) {
88 PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC,ERR_R_MALLOC_FAILURE); 89 PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC,ERR_R_MALLOC_FAILURE);
89 return 0; 90 return 0;
90 } 91 }
91 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, 92 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen,
92 id, iter, n, out, md_type); 93 id, iter, n, out, md_type);
94 if (ret <= 0)
95 return 0;
93 if(unipass) { 96 if(unipass) {
94 OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */ 97 OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */
95 OPENSSL_free(unipass); 98 OPENSSL_free(unipass);
@@ -129,6 +132,8 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
129#endif 132#endif
130 v = EVP_MD_block_size (md_type); 133 v = EVP_MD_block_size (md_type);
131 u = EVP_MD_size (md_type); 134 u = EVP_MD_size (md_type);
135 if (u < 0)
136 return 0;
132 D = OPENSSL_malloc (v); 137 D = OPENSSL_malloc (v);
133 Ai = OPENSSL_malloc (u); 138 Ai = OPENSSL_malloc (u);
134 B = OPENSSL_malloc (v + 1); 139 B = OPENSSL_malloc (v + 1);