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