提交 e8503762 编写于 作者: D Dr. Stephen Henson

Rename PKCS12 function

Rename ancient PKCS12 functions to use more logical names. Include
defines from old to new name.
Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 776cfa9b
......@@ -130,39 +130,39 @@ PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12)
}
#endif
PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509)
PKCS12_SAFEBAG *PKCS12_SAFEBAG_new_cert(X509 *x509)
{
return PKCS12_item_pack_safebag(x509, ASN1_ITEM_rptr(X509),
NID_x509Certificate, NID_certBag);
}
PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl)
PKCS12_SAFEBAG *PKCS12_SAFEBAG_new_crl(X509_CRL *crl)
{
return PKCS12_item_pack_safebag(crl, ASN1_ITEM_rptr(X509_CRL),
NID_x509Crl, NID_crlBag);
}
X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag)
X509 *PKCS12_SAFEBAG_get1_cert(PKCS12_SAFEBAG *bag)
{
if (PKCS12_bag_type(bag) != NID_certBag)
if (PKCS12_SAFEBAG_get_nid(bag) != NID_certBag)
return NULL;
if (PKCS12_cert_bag_type(bag) != NID_x509Certificate)
if (OBJ_obj2nid(bag->value.bag->type) != NID_x509Certificate)
return NULL;
return ASN1_item_unpack(bag->value.bag->value.octet,
ASN1_ITEM_rptr(X509));
}
X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag)
X509_CRL *PKCS12_SAFEBAG_get1_crl(PKCS12_SAFEBAG *bag)
{
if (PKCS12_bag_type(bag) != NID_crlBag)
if (PKCS12_SAFEBAG_get_nid(bag) != NID_crlBag)
return NULL;
if (PKCS12_cert_bag_type(bag) != NID_x509Crl)
if (OBJ_obj2nid(bag->value.bag->type) != NID_x509Crl)
return NULL;
return ASN1_item_unpack(bag->value.bag->value.octet,
ASN1_ITEM_rptr(X509_CRL));
}
ASN1_TYPE *PKCS12_get_attr(PKCS12_SAFEBAG *bag, int attr_nid)
ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(PKCS12_SAFEBAG *bag, int attr_nid)
{
return PKCS12_get_attr_gen(bag->attrib, attr_nid);
}
......@@ -202,21 +202,9 @@ void PKCS12_get0_mac(ASN1_OCTET_STRING **pmac, X509_ALGOR **pmacalg,
}
}
int PKCS12_bag_type(PKCS12_SAFEBAG *bag)
{
return OBJ_obj2nid(bag->type);
}
int PKCS12_cert_bag_type(PKCS12_SAFEBAG *bag)
{
if (PKCS12_bag_type(bag) != NID_certBag)
return -1;
return OBJ_obj2nid(bag->value.bag->type);
}
PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(PKCS12_SAFEBAG *bag)
{
if (PKCS12_bag_type(bag) != NID_keyBag)
if (PKCS12_SAFEBAG_get_nid(bag) != NID_keyBag)
return NULL;
return bag->value.keybag;
}
......@@ -239,3 +227,16 @@ ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(PKCS12_SAFEBAG *bag)
{
return bag->type;
}
int PKCS12_SAFEBAG_get_nid(PKCS12_SAFEBAG *bag)
{
return OBJ_obj2nid(bag->type);
}
int PKCS12_SAFEBAG_get_bag_nid(PKCS12_SAFEBAG *bag)
{
int btype = PKCS12_SAFEBAG_get_nid(bag);
if (btype != NID_certBag || btype != NID_crlBag || btype != NID_secretBag)
return -1;
return OBJ_obj2nid(bag->value.bag->type);
}
......@@ -131,23 +131,32 @@ typedef struct pkcs12_bag_st PKCS12_BAGS;
# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type
# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type
ASN1_TYPE *PKCS12_get_attr(PKCS12_SAFEBAG *bag, int attr_nid);
/* Compatibility macros for pre 1.1.0 function names */
# define PKCS12_x5092certbag PKCS12_SAFEBAG_new_cert
# define PKCS12_crl2certbag PKCS12_SAFEBAG_new_crl
# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert
# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl
# define PKCS12_get_attr PKCS12_SAFEBAG_get0_attr
# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid
# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid
ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(PKCS12_SAFEBAG *bag, int attr_nid);
ASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid);
int PKCS12_mac_present(PKCS12 *p12);
void PKCS12_get0_mac(ASN1_OCTET_STRING **pmac, X509_ALGOR **pmacalg,
ASN1_OCTET_STRING **psalt, ASN1_INTEGER **piter,
PKCS12 *p12);
int PKCS12_bag_type(PKCS12_SAFEBAG *bag);
int PKCS12_cert_bag_type(PKCS12_SAFEBAG *bag);
int PKCS12_SAFEBAG_get_nid(PKCS12_SAFEBAG *bag);
int PKCS12_SAFEBAG_get_bag_nid(PKCS12_SAFEBAG *bag);
PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(PKCS12_SAFEBAG *bag);
X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(PKCS12_SAFEBAG *bag);
STACK_OF(PKCS12_SAFEBAG) *PKCS12_SAFEBAG_get0_safes(PKCS12_SAFEBAG *bag);
ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(PKCS12_SAFEBAG *bag);
PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);
PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);
X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);
X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_new_cert(X509 *x509);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_new_crl(X509_CRL *crl);
X509 *PKCS12_SAFEBAG_get1_cert(PKCS12_SAFEBAG *bag);
X509_CRL *PKCS12_SAFEBAG_get1_crl(PKCS12_SAFEBAG *bag);
PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,
int nid1, int nid2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册