p12_kiss.c (302408) | p12_kiss.c (325337) |
---|---|
1/* p12_kiss.c */ 2/* 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4 * 1999. 5 */ 6/* ==================================================================== 7 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 8 * --- 70 unchanged lines hidden (view full) --- 79 * unitialised. 80 */ 81 82int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, 83 STACK_OF(X509) **ca) 84{ 85 STACK_OF(X509) *ocerts = NULL; 86 X509 *x = NULL; | 1/* p12_kiss.c */ 2/* 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4 * 1999. 5 */ 6/* ==================================================================== 7 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 8 * --- 70 unchanged lines hidden (view full) --- 79 * unitialised. 80 */ 81 82int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, 83 STACK_OF(X509) **ca) 84{ 85 STACK_OF(X509) *ocerts = NULL; 86 X509 *x = NULL; |
87 88 if (pkey) 89 *pkey = NULL; 90 if (cert) 91 *cert = NULL; 92 |
|
87 /* Check for NULL PKCS12 structure */ 88 89 if (!p12) { 90 PKCS12err(PKCS12_F_PKCS12_PARSE, 91 PKCS12_R_INVALID_NULL_PKCS12_POINTER); 92 return 0; 93 } 94 | 93 /* Check for NULL PKCS12 structure */ 94 95 if (!p12) { 96 PKCS12err(PKCS12_F_PKCS12_PARSE, 97 PKCS12_R_INVALID_NULL_PKCS12_POINTER); 98 return 0; 99 } 100 |
95 if (pkey) 96 *pkey = NULL; 97 if (cert) 98 *cert = NULL; 99 | |
100 /* Check the mac */ 101 102 /* 103 * If password is zero length or NULL then try verifying both cases to 104 * determine which password is correct. The reason for this is that under 105 * PKCS#12 password based encryption no password and a zero length 106 * password are two different things... 107 */ --- 12 unchanged lines hidden (view full) --- 120 goto err; 121 } 122 123 /* Allocate stack for other certificates */ 124 ocerts = sk_X509_new_null(); 125 126 if (!ocerts) { 127 PKCS12err(PKCS12_F_PKCS12_PARSE, ERR_R_MALLOC_FAILURE); | 101 /* Check the mac */ 102 103 /* 104 * If password is zero length or NULL then try verifying both cases to 105 * determine which password is correct. The reason for this is that under 106 * PKCS#12 password based encryption no password and a zero length 107 * password are two different things... 108 */ --- 12 unchanged lines hidden (view full) --- 121 goto err; 122 } 123 124 /* Allocate stack for other certificates */ 125 ocerts = sk_X509_new_null(); 126 127 if (!ocerts) { 128 PKCS12err(PKCS12_F_PKCS12_PARSE, ERR_R_MALLOC_FAILURE); |
128 return 0; | 129 goto err; |
129 } 130 131 if (!parse_pk12(p12, pass, -1, pkey, ocerts)) { 132 PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_PARSE_ERROR); 133 goto err; 134 } 135 136 while ((x = sk_X509_pop(ocerts))) { --- 21 unchanged lines hidden (view full) --- 158 159 if (ocerts) 160 sk_X509_pop_free(ocerts, X509_free); 161 162 return 1; 163 164 err: 165 | 130 } 131 132 if (!parse_pk12(p12, pass, -1, pkey, ocerts)) { 133 PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_PARSE_ERROR); 134 goto err; 135 } 136 137 while ((x = sk_X509_pop(ocerts))) { --- 21 unchanged lines hidden (view full) --- 159 160 if (ocerts) 161 sk_X509_pop_free(ocerts, X509_free); 162 163 return 1; 164 165 err: 166 |
166 if (pkey && *pkey) | 167 if (pkey) { |
167 EVP_PKEY_free(*pkey); | 168 EVP_PKEY_free(*pkey); |
168 if (cert && *cert) | 169 *pkey = NULL; 170 } 171 if (cert) { |
169 X509_free(*cert); | 172 X509_free(*cert); |
173 *cert = NULL; 174 } |
|
170 if (x) 171 X509_free(x); 172 if (ocerts) 173 sk_X509_pop_free(ocerts, X509_free); 174 return 0; 175 176} 177 --- 122 unchanged lines hidden --- | 175 if (x) 176 X509_free(x); 177 if (ocerts) 178 sk_X509_pop_free(ocerts, X509_free); 179 return 0; 180 181} 182 --- 122 unchanged lines hidden --- |