summaryrefslogtreecommitdiff
path: root/drivers/builtin_openssl2/crypto/pkcs12/p12_attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/builtin_openssl2/crypto/pkcs12/p12_attr.c')
-rw-r--r--drivers/builtin_openssl2/crypto/pkcs12/p12_attr.c110
1 files changed, 56 insertions, 54 deletions
diff --git a/drivers/builtin_openssl2/crypto/pkcs12/p12_attr.c b/drivers/builtin_openssl2/crypto/pkcs12/p12_attr.c
index e4d9c25647..fff3ba1ece 100644
--- a/drivers/builtin_openssl2/crypto/pkcs12/p12_attr.c
+++ b/drivers/builtin_openssl2/crypto/pkcs12/p12_attr.c
@@ -1,6 +1,7 @@
/* p12_attr.c */
-/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
- * project 1999.
+/*
+ * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
+ * 1999.
*/
/* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
@@ -10,7 +11,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -63,83 +64,84 @@
/* Add a local keyid to a safebag */
int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,
- int namelen)
+ int namelen)
{
- if (X509at_add1_attr_by_NID(&bag->attrib, NID_localKeyID,
- V_ASN1_OCTET_STRING, name, namelen))
- return 1;
- else
- return 0;
+ if (X509at_add1_attr_by_NID(&bag->attrib, NID_localKeyID,
+ V_ASN1_OCTET_STRING, name, namelen))
+ return 1;
+ else
+ return 0;
}
/* Add key usage to PKCS#8 structure */
int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage)
{
- unsigned char us_val;
- us_val = (unsigned char) usage;
- if (X509at_add1_attr_by_NID(&p8->attributes, NID_key_usage,
- V_ASN1_BIT_STRING, &us_val, 1))
- return 1;
- else
- return 0;
+ unsigned char us_val;
+ us_val = (unsigned char)usage;
+ if (X509at_add1_attr_by_NID(&p8->attributes, NID_key_usage,
+ V_ASN1_BIT_STRING, &us_val, 1))
+ return 1;
+ else
+ return 0;
}
/* Add a friendlyname to a safebag */
int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
- int namelen)
+ int namelen)
{
- if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName,
- MBSTRING_ASC, (unsigned char *)name, namelen))
- return 1;
- else
- return 0;
+ if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName,
+ MBSTRING_ASC, (unsigned char *)name, namelen))
+ return 1;
+ else
+ return 0;
}
-
int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
- const unsigned char *name, int namelen)
+ const unsigned char *name, int namelen)
{
- if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName,
- MBSTRING_BMP, name, namelen))
- return 1;
- else
- return 0;
+ if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName,
+ MBSTRING_BMP, name, namelen))
+ return 1;
+ else
+ return 0;
}
-int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
- int namelen)
+int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen)
{
- if (X509at_add1_attr_by_NID(&bag->attrib, NID_ms_csp_name,
- MBSTRING_ASC, (unsigned char *)name, namelen))
- return 1;
- else
- return 0;
+ if (X509at_add1_attr_by_NID(&bag->attrib, NID_ms_csp_name,
+ MBSTRING_ASC, (unsigned char *)name, namelen))
+ return 1;
+ else
+ return 0;
}
ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid)
{
- X509_ATTRIBUTE *attrib;
- int i;
- if (!attrs) return NULL;
- for (i = 0; i < sk_X509_ATTRIBUTE_num (attrs); i++) {
- attrib = sk_X509_ATTRIBUTE_value (attrs, i);
- if (OBJ_obj2nid (attrib->object) == attr_nid) {
- if (sk_ASN1_TYPE_num (attrib->value.set))
- return sk_ASN1_TYPE_value(attrib->value.set, 0);
- else return NULL;
- }
- }
- return NULL;
+ X509_ATTRIBUTE *attrib;
+ int i;
+ if (!attrs)
+ return NULL;
+ for (i = 0; i < sk_X509_ATTRIBUTE_num(attrs); i++) {
+ attrib = sk_X509_ATTRIBUTE_value(attrs, i);
+ if (OBJ_obj2nid(attrib->object) == attr_nid) {
+ if (sk_ASN1_TYPE_num(attrib->value.set))
+ return sk_ASN1_TYPE_value(attrib->value.set, 0);
+ else
+ return NULL;
+ }
+ }
+ return NULL;
}
char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag)
{
- ASN1_TYPE *atype;
- if (!(atype = PKCS12_get_attr(bag, NID_friendlyName))) return NULL;
- if (atype->type != V_ASN1_BMPSTRING) return NULL;
- return OPENSSL_uni2asc(atype->value.bmpstring->data,
- atype->value.bmpstring->length);
+ ASN1_TYPE *atype;
+ if (!(atype = PKCS12_get_attr(bag, NID_friendlyName)))
+ return NULL;
+ if (atype->type != V_ASN1_BMPSTRING)
+ return NULL;
+ return OPENSSL_uni2asc(atype->value.bmpstring->data,
+ atype->value.bmpstring->length);
}
-