Loading apps/pkcs12.c +10 −9 Original line number Diff line number Diff line Loading @@ -362,7 +362,7 @@ int MAIN(int argc, char **argv) if (export_cert) { EVP_PKEY *key; STACK_OF(PKCS12_SAFEBAG) *bags; STACK *safes; STACK_OF(PKCS7) *safes; PKCS12_SAFEBAG *bag; PKCS8_PRIV_KEY_INFO *p8; PKCS7 *authsafe; Loading Loading @@ -468,8 +468,8 @@ int MAIN(int argc, char **argv) goto end; } safes = sk_new (NULL); sk_push (safes, (char *)authsafe); safes = sk_PKCS7_new (NULL); sk_PKCS7_push (safes, authsafe); /* Make a shrouded key bag */ p8 = EVP_PKEY2PKCS8 (key); Loading @@ -484,13 +484,13 @@ int MAIN(int argc, char **argv) /* Turn it into unencrypted safe bag */ authsafe = PKCS12_pack_p7data (bags); sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); sk_push (safes, (char *)authsafe); sk_PKCS7_push (safes, authsafe); p12 = PKCS12_init (NID_pkcs7_data); M_PKCS12_pack_authsafes (p12, safes); sk_pop_free(safes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(safes, PKCS7_free); PKCS12_set_mac (p12, mpass, -1, NULL, 0, maciter, NULL); Loading Loading @@ -573,13 +573,14 @@ int MAIN(int argc, char **argv) int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, int passlen, int options, char *pempass) { STACK *asafes; STACK_OF(PKCS7) *asafes; STACK_OF(PKCS12_SAFEBAG) *bags; int i, bagnid; PKCS7 *p7; if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0; for (i = 0; i < sk_num (asafes); i++) { p7 = (PKCS7 *) sk_value (asafes, i); for (i = 0; i < sk_PKCS7_num (asafes); i++) { p7 = sk_PKCS7_value (asafes, i); bagnid = OBJ_obj2nid (p7->type); if (bagnid == NID_pkcs7_data) { bags = M_PKCS12_unpack_p7data (p7); Loading @@ -600,7 +601,7 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, } sk_PKCS12_SAFEBAG_pop_free (bags, PKCS12_SAFEBAG_free); } sk_pop_free (asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free (asafes, PKCS7_free); return 1; } Loading crypto/asn1/p7_lib.c +2 −0 Original line number Diff line number Diff line Loading @@ -293,3 +293,5 @@ void PKCS7_content_free(PKCS7 *a) a->d.ptr=NULL; } IMPLEMENT_STACK_OF(PKCS7) IMPLEMENT_ASN1_SET_OF(PKCS7) crypto/pkcs12/p12_crt.c +5 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, { PKCS12 *p12; STACK_OF(PKCS12_SAFEBAG) *bags; STACK *safes; STACK_OF(PKCS7) *safes; PKCS12_SAFEBAG *bag; PKCS8_PRIV_KEY_INFO *p8; PKCS7 *authsafe; Loading Loading @@ -121,7 +121,8 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, if (!authsafe) return NULL; if(!(safes = sk_new (NULL)) || !sk_push(safes, (char *)authsafe)) { if(!(safes = sk_PKCS7_new (NULL)) || !sk_PKCS7_push(safes, authsafe)) { PKCS12err(PKCS12_F_PKCS12_CREATE,ERR_R_MALLOC_FAILURE); return NULL; } Loading @@ -142,7 +143,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, /* Turn it into unencrypted safe bag */ if(!(authsafe = PKCS12_pack_p7data (bags))) return NULL; sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); if(!sk_push(safes, (char *)authsafe)) { if(!sk_PKCS7_push(safes, authsafe)) { PKCS12err(PKCS12_F_PKCS12_CREATE,ERR_R_MALLOC_FAILURE); return NULL; } Loading @@ -151,7 +152,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, if(!M_PKCS12_pack_authsafes (p12, safes)) return NULL; sk_pop_free(safes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(safes, PKCS7_free); if(!PKCS12_set_mac (p12, pass, -1, NULL, 0, mac_iter, NULL)) return NULL; Loading crypto/pkcs12/p12_decr.c +2 −0 Original line number Diff line number Diff line Loading @@ -183,3 +183,5 @@ ASN1_OCTET_STRING *PKCS12_i2d_encrypt (X509_ALGOR *algor, int (*i2d)(), Free (in); return oct; } IMPLEMENT_PKCS12_STACK_OF(PKCS7) crypto/pkcs12/p12_kiss.c +7 −6 Original line number Diff line number Diff line Loading @@ -147,15 +147,16 @@ int PKCS12_parse (PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca) { STACK *asafes; STACK_OF(PKCS7) *asafes; STACK_OF(PKCS12_SAFEBAG) *bags; int i, bagnid; PKCS7 *p7; ASN1_OCTET_STRING *keyid = NULL; char keymatch = 0; if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0; for (i = 0; i < sk_num (asafes); i++) { p7 = (PKCS7 *) sk_value (asafes, i); for (i = 0; i < sk_PKCS7_num (asafes); i++) { p7 = sk_PKCS7_value (asafes, i); bagnid = OBJ_obj2nid (p7->type); if (bagnid == NID_pkcs7_data) { bags = M_PKCS12_unpack_p7data (p7); Loading @@ -163,18 +164,18 @@ static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen, bags = M_PKCS12_unpack_p7encdata (p7, pass, passlen); } else continue; if (!bags) { sk_pop_free (asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free (asafes, PKCS7_free); return 0; } if (!parse_bags(bags, pass, passlen, pkey, cert, ca, &keyid, &keymatch)) { sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); sk_pop_free(asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(asafes, PKCS7_free); return 0; } sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); } sk_pop_free(asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(asafes, PKCS7_free); if (keyid) M_ASN1_OCTET_STRING_free(keyid); return 1; } Loading Loading
apps/pkcs12.c +10 −9 Original line number Diff line number Diff line Loading @@ -362,7 +362,7 @@ int MAIN(int argc, char **argv) if (export_cert) { EVP_PKEY *key; STACK_OF(PKCS12_SAFEBAG) *bags; STACK *safes; STACK_OF(PKCS7) *safes; PKCS12_SAFEBAG *bag; PKCS8_PRIV_KEY_INFO *p8; PKCS7 *authsafe; Loading Loading @@ -468,8 +468,8 @@ int MAIN(int argc, char **argv) goto end; } safes = sk_new (NULL); sk_push (safes, (char *)authsafe); safes = sk_PKCS7_new (NULL); sk_PKCS7_push (safes, authsafe); /* Make a shrouded key bag */ p8 = EVP_PKEY2PKCS8 (key); Loading @@ -484,13 +484,13 @@ int MAIN(int argc, char **argv) /* Turn it into unencrypted safe bag */ authsafe = PKCS12_pack_p7data (bags); sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); sk_push (safes, (char *)authsafe); sk_PKCS7_push (safes, authsafe); p12 = PKCS12_init (NID_pkcs7_data); M_PKCS12_pack_authsafes (p12, safes); sk_pop_free(safes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(safes, PKCS7_free); PKCS12_set_mac (p12, mpass, -1, NULL, 0, maciter, NULL); Loading Loading @@ -573,13 +573,14 @@ int MAIN(int argc, char **argv) int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, int passlen, int options, char *pempass) { STACK *asafes; STACK_OF(PKCS7) *asafes; STACK_OF(PKCS12_SAFEBAG) *bags; int i, bagnid; PKCS7 *p7; if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0; for (i = 0; i < sk_num (asafes); i++) { p7 = (PKCS7 *) sk_value (asafes, i); for (i = 0; i < sk_PKCS7_num (asafes); i++) { p7 = sk_PKCS7_value (asafes, i); bagnid = OBJ_obj2nid (p7->type); if (bagnid == NID_pkcs7_data) { bags = M_PKCS12_unpack_p7data (p7); Loading @@ -600,7 +601,7 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, } sk_PKCS12_SAFEBAG_pop_free (bags, PKCS12_SAFEBAG_free); } sk_pop_free (asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free (asafes, PKCS7_free); return 1; } Loading
crypto/asn1/p7_lib.c +2 −0 Original line number Diff line number Diff line Loading @@ -293,3 +293,5 @@ void PKCS7_content_free(PKCS7 *a) a->d.ptr=NULL; } IMPLEMENT_STACK_OF(PKCS7) IMPLEMENT_ASN1_SET_OF(PKCS7)
crypto/pkcs12/p12_crt.c +5 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, { PKCS12 *p12; STACK_OF(PKCS12_SAFEBAG) *bags; STACK *safes; STACK_OF(PKCS7) *safes; PKCS12_SAFEBAG *bag; PKCS8_PRIV_KEY_INFO *p8; PKCS7 *authsafe; Loading Loading @@ -121,7 +121,8 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, if (!authsafe) return NULL; if(!(safes = sk_new (NULL)) || !sk_push(safes, (char *)authsafe)) { if(!(safes = sk_PKCS7_new (NULL)) || !sk_PKCS7_push(safes, authsafe)) { PKCS12err(PKCS12_F_PKCS12_CREATE,ERR_R_MALLOC_FAILURE); return NULL; } Loading @@ -142,7 +143,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, /* Turn it into unencrypted safe bag */ if(!(authsafe = PKCS12_pack_p7data (bags))) return NULL; sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); if(!sk_push(safes, (char *)authsafe)) { if(!sk_PKCS7_push(safes, authsafe)) { PKCS12err(PKCS12_F_PKCS12_CREATE,ERR_R_MALLOC_FAILURE); return NULL; } Loading @@ -151,7 +152,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, if(!M_PKCS12_pack_authsafes (p12, safes)) return NULL; sk_pop_free(safes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(safes, PKCS7_free); if(!PKCS12_set_mac (p12, pass, -1, NULL, 0, mac_iter, NULL)) return NULL; Loading
crypto/pkcs12/p12_decr.c +2 −0 Original line number Diff line number Diff line Loading @@ -183,3 +183,5 @@ ASN1_OCTET_STRING *PKCS12_i2d_encrypt (X509_ALGOR *algor, int (*i2d)(), Free (in); return oct; } IMPLEMENT_PKCS12_STACK_OF(PKCS7)
crypto/pkcs12/p12_kiss.c +7 −6 Original line number Diff line number Diff line Loading @@ -147,15 +147,16 @@ int PKCS12_parse (PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca) { STACK *asafes; STACK_OF(PKCS7) *asafes; STACK_OF(PKCS12_SAFEBAG) *bags; int i, bagnid; PKCS7 *p7; ASN1_OCTET_STRING *keyid = NULL; char keymatch = 0; if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0; for (i = 0; i < sk_num (asafes); i++) { p7 = (PKCS7 *) sk_value (asafes, i); for (i = 0; i < sk_PKCS7_num (asafes); i++) { p7 = sk_PKCS7_value (asafes, i); bagnid = OBJ_obj2nid (p7->type); if (bagnid == NID_pkcs7_data) { bags = M_PKCS12_unpack_p7data (p7); Loading @@ -163,18 +164,18 @@ static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen, bags = M_PKCS12_unpack_p7encdata (p7, pass, passlen); } else continue; if (!bags) { sk_pop_free (asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free (asafes, PKCS7_free); return 0; } if (!parse_bags(bags, pass, passlen, pkey, cert, ca, &keyid, &keymatch)) { sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); sk_pop_free(asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(asafes, PKCS7_free); return 0; } sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); } sk_pop_free(asafes, (void(*)(void *)) PKCS7_free); sk_PKCS7_pop_free(asafes, PKCS7_free); if (keyid) M_ASN1_OCTET_STRING_free(keyid); return 1; } Loading