summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs12
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pkcs12')
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c9
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c16
-rw-r--r--src/lib/libcrypto/pkcs12/p12_kiss.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_mutl.c12
4 files changed, 26 insertions, 13 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index ba77dbbe32..9d3557e8d7 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -89,7 +89,14 @@ unsigned char * PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
89 goto err; 89 goto err;
90 } 90 }
91 91
92 EVP_CipherUpdate(&ctx, out, &i, in, inlen); 92 if (!EVP_CipherUpdate(&ctx, out, &i, in, inlen))
93 {
94 OPENSSL_free(out);
95 out = NULL;
96 PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_EVP_LIB);
97 goto err;
98 }
99
93 outlen = i; 100 outlen = i;
94 if(!EVP_CipherFinal_ex(&ctx, out + i, &i)) { 101 if(!EVP_CipherFinal_ex(&ctx, out + i, &i)) {
95 OPENSSL_free(out); 102 OPENSSL_free(out);
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 424203f648..c55c7b60b3 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -152,14 +152,16 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
152 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen]; 152 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen];
153 for (i = 0; i < Plen; i++) *p++ = pass[i % passlen]; 153 for (i = 0; i < Plen; i++) *p++ = pass[i % passlen];
154 for (;;) { 154 for (;;) {
155 EVP_DigestInit_ex(&ctx, md_type, NULL); 155 if (!EVP_DigestInit_ex(&ctx, md_type, NULL)
156 EVP_DigestUpdate(&ctx, D, v); 156 || !EVP_DigestUpdate(&ctx, D, v)
157 EVP_DigestUpdate(&ctx, I, Ilen); 157 || !EVP_DigestUpdate(&ctx, I, Ilen)
158 EVP_DigestFinal_ex(&ctx, Ai, NULL); 158 || !EVP_DigestFinal_ex(&ctx, Ai, NULL))
159 goto err;
159 for (j = 1; j < iter; j++) { 160 for (j = 1; j < iter; j++) {
160 EVP_DigestInit_ex(&ctx, md_type, NULL); 161 if (!EVP_DigestInit_ex(&ctx, md_type, NULL)
161 EVP_DigestUpdate(&ctx, Ai, u); 162 || !EVP_DigestUpdate(&ctx, Ai, u)
162 EVP_DigestFinal_ex(&ctx, Ai, NULL); 163 || !EVP_DigestFinal_ex(&ctx, Ai, NULL))
164 goto err;
163 } 165 }
164 memcpy (out, Ai, min (n, u)); 166 memcpy (out, Ai, min (n, u));
165 if (u >= n) { 167 if (u >= n) {
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c
index 292cc3ed4a..206b1b0b18 100644
--- a/src/lib/libcrypto/pkcs12/p12_kiss.c
+++ b/src/lib/libcrypto/pkcs12/p12_kiss.c
@@ -167,7 +167,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
167 if (cert && *cert) 167 if (cert && *cert)
168 X509_free(*cert); 168 X509_free(*cert);
169 if (x) 169 if (x)
170 X509_free(*cert); 170 X509_free(x);
171 if (ocerts) 171 if (ocerts)
172 sk_X509_pop_free(ocerts, X509_free); 172 sk_X509_pop_free(ocerts, X509_free);
173 return 0; 173 return 0;
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c
index 9ab740d51f..96de1bd11e 100644
--- a/src/lib/libcrypto/pkcs12/p12_mutl.c
+++ b/src/lib/libcrypto/pkcs12/p12_mutl.c
@@ -97,10 +97,14 @@ int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
97 return 0; 97 return 0;
98 } 98 }
99 HMAC_CTX_init(&hmac); 99 HMAC_CTX_init(&hmac);
100 HMAC_Init_ex(&hmac, key, md_size, md_type, NULL); 100 if (!HMAC_Init_ex(&hmac, key, md_size, md_type, NULL)
101 HMAC_Update(&hmac, p12->authsafes->d.data->data, 101 || !HMAC_Update(&hmac, p12->authsafes->d.data->data,
102 p12->authsafes->d.data->length); 102 p12->authsafes->d.data->length)
103 HMAC_Final(&hmac, mac, maclen); 103 || !HMAC_Final(&hmac, mac, maclen))
104 {
105 HMAC_CTX_cleanup(&hmac);
106 return 0;
107 }
104 HMAC_CTX_cleanup(&hmac); 108 HMAC_CTX_cleanup(&hmac);
105 return 1; 109 return 1;
106} 110}