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

pkcs12 accessors

Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 03922a63
......@@ -137,3 +137,8 @@ char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag)
return OPENSSL_uni2asc(atype->value.bmpstring->data,
atype->value.bmpstring->length);
}
STACK_OF(X509_ATTRIBUTE) *PKCS12_SAFEBAG_get0_attrs(PKCS12_SAFEBAG *bag)
{
return bag->attrib;
}
......@@ -177,6 +177,31 @@ int PKCS12_mac_present(PKCS12 *p12)
return p12->mac ? 1 : 0;
}
void PKCS12_get0_mac(ASN1_OCTET_STRING **pmac, X509_ALGOR **pmacalg,
ASN1_OCTET_STRING **psalt, ASN1_INTEGER **piter,
PKCS12 *p12)
{
if (p12->mac) {
if (pmac)
*pmac = p12->mac->dinfo->digest;
if (pmacalg)
*pmacalg = p12->mac->dinfo->algor;
if (psalt)
*psalt = p12->mac->salt;
if (piter)
*piter = p12->mac->iter;
} else {
if (pmac)
*pmac = NULL;
if (pmacalg)
*pmacalg = NULL;
if (psalt)
*psalt = NULL;
if (piter)
*piter = NULL;
}
}
int PKCS12_bag_type(PKCS12_SAFEBAG *bag)
{
return OBJ_obj2nid(bag->type);
......@@ -196,9 +221,21 @@ PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(PKCS12_SAFEBAG *bag)
return bag->value.keybag;
}
X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(PKCS12_SAFEBAG *bag)
{
if (OBJ_obj2nid(bag->type) != NID_pkcs8ShroudedKeyBag)
return NULL;
return bag->value.shkeybag;
}
STACK_OF(PKCS12_SAFEBAG) *PKCS12_SAFEBAG_get0_safes(PKCS12_SAFEBAG *bag)
{
if (OBJ_obj2nid(bag->type) != NID_safeContentsBag)
return NULL;
return bag->value.safes;
}
ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(PKCS12_SAFEBAG *bag)
{
return bag->type;
}
......@@ -134,10 +134,15 @@ typedef struct pkcs12_bag_st PKCS12_BAGS;
ASN1_TYPE *PKCS12_get_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);
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);
......@@ -182,6 +187,7 @@ int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);
char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
STACK_OF(X509_ATTRIBUTE) *PKCS12_SAFEBAG_get0_attrs(PKCS12_SAFEBAG *bag);
unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
int passlen, unsigned char *in, int inlen,
unsigned char **data, int *datalen,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册