summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs12/p12_attr.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2015-03-20 15:28:40 +0000
committerjkim <jkim@FreeBSD.org>2015-03-20 15:28:40 +0000
commit038f65e5fb1f35e1e485aa4781cda353c4e903f4 (patch)
tree787cdff35e35be75e53f378b098bba3237a8deb7 /crypto/pkcs12/p12_attr.c
parent63414ee1a3b7c1a972b52637c01b95212e3b51ea (diff)
downloadFreeBSD-src-038f65e5fb1f35e1e485aa4781cda353c4e903f4.zip
FreeBSD-src-038f65e5fb1f35e1e485aa4781cda353c4e903f4.tar.gz
Import OpenSSL 1.0.1m.
Diffstat (limited to 'crypto/pkcs12/p12_attr.c')
-rw-r--r--crypto/pkcs12/p12_attr.c110
1 files changed, 56 insertions, 54 deletions
diff --git a/crypto/pkcs12/p12_attr.c b/crypto/pkcs12/p12_attr.c
index e4d9c25..fff3ba1 100644
--- a/crypto/pkcs12/p12_attr.c
+++ b/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);
}
-
OpenPOWER on IntegriCloud