summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/pkcs12/p12_kiss.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/crypto/pkcs12/p12_kiss.c b/crypto/pkcs12/p12_kiss.c
index ed1105cee4..6d99900077 100644
--- a/crypto/pkcs12/p12_kiss.c
+++ b/crypto/pkcs12/p12_kiss.c
@@ -49,27 +49,28 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
}
/* Check the mac */
-
- /*
- * If password is zero length or NULL then try verifying both cases to
- * determine which password is correct. The reason for this is that under
- * PKCS#12 password based encryption no password and a zero length
- * password are two different things...
- */
-
- if (pass == NULL || *pass == '\0') {
- if (!PKCS12_mac_present(p12)
- || PKCS12_verify_mac(p12, NULL, 0))
- pass = NULL;
- else if (PKCS12_verify_mac(p12, "", 0))
- pass = "";
- else {
+ if (PKCS12_mac_present(p12)) {
+ /*
+ * If password is zero length or NULL then try verifying both cases to
+ * determine which password is correct. The reason for this is that under
+ * PKCS#12 password based encryption no password and a zero length
+ * password are two different things...
+ */
+ if (pass == NULL || *pass == '\0') {
+ if (PKCS12_verify_mac(p12, NULL, 0))
+ pass = NULL;
+ else if (PKCS12_verify_mac(p12, "", 0))
+ pass = "";
+ else {
+ ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_VERIFY_FAILURE);
+ goto err;
+ }
+ } else if (!PKCS12_verify_mac(p12, pass, -1)) {
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_VERIFY_FAILURE);
goto err;
}
- } else if (!PKCS12_verify_mac(p12, pass, -1)) {
- ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_VERIFY_FAILURE);
- goto err;
+ } else if (pass == NULL || *pass == '\0') {
+ pass = NULL;
}
/* If needed, allocate stack for other certificates */