summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs12/p12_npas.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pkcs12/p12_npas.c')
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
index af708a2743..48eacc5c49 100644
--- a/src/lib/libcrypto/pkcs12/p12_npas.c
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -77,28 +77,26 @@ static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen);
77 77
78int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass) 78int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass)
79{ 79{
80 /* Check for NULL PKCS12 structure */
80 81
81/* Check for NULL PKCS12 structure */ 82 if(!p12) {
82 83 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_INVALID_NULL_PKCS12_POINTER);
83if(!p12) { 84 return 0;
84 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_INVALID_NULL_PKCS12_POINTER); 85 }
85 return 0;
86}
87
88/* Check the mac */
89
90if (!PKCS12_verify_mac(p12, oldpass, -1)) {
91 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_MAC_VERIFY_FAILURE);
92 return 0;
93}
94 86
95if (!newpass_p12(p12, oldpass, newpass)) { 87 /* Check the mac */
96 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_PARSE_ERROR); 88
97 return 0; 89 if (!PKCS12_verify_mac(p12, oldpass, -1)) {
98} 90 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_MAC_VERIFY_FAILURE);
91 return 0;
92 }
99 93
100return 1; 94 if (!newpass_p12(p12, oldpass, newpass)) {
95 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_PARSE_ERROR);
96 return 0;
97 }
101 98
99 return 1;
102} 100}
103 101
104/* Parse the outer PKCS#12 structure */ 102/* Parse the outer PKCS#12 structure */
@@ -206,7 +204,8 @@ static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass)
206static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen) 204static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen)
207{ 205{
208 PBEPARAM *pbe; 206 PBEPARAM *pbe;
209 unsigned char *p; 207 const unsigned char *p;
208
210 p = alg->parameter->value.sequence->data; 209 p = alg->parameter->value.sequence->data;
211 pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length); 210 pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
212 *pnid = OBJ_obj2nid(alg->algorithm); 211 *pnid = OBJ_obj2nid(alg->algorithm);