summaryrefslogtreecommitdiffstats
path: root/crypto/x509/x509_att.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-02-11 17:52:38 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-02-11 17:52:38 +0000
commit4d318c79b27925911f5822c5b8eaef2624bc9055 (patch)
tree406edd87f9e0c9368dcf34215c9114c8b6761cd8 /crypto/x509/x509_att.c
parent1ad90a916b4e3295173853d5da7f6a68cbad53f1 (diff)
Utility attribute function to retrieve attribute data from an expected
type. Useful for many attributes which are single valued and can only have one type.
Diffstat (limited to 'crypto/x509/x509_att.c')
-rw-r--r--crypto/x509/x509_att.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/x509/x509_att.c b/crypto/x509/x509_att.c
index 2a8cc0c4b0..9245bfd9f5 100644
--- a/crypto/x509/x509_att.c
+++ b/crypto/x509/x509_att.c
@@ -193,6 +193,22 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
return ret;
}
+void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
+ ASN1_OBJECT *obj, int lastpos, int type)
+{
+ int i;
+ X509_ATTRIBUTE *at;
+ i = X509at_get_attr_by_OBJ(x, obj, lastpos);
+ if (i == -1)
+ return NULL;
+ if ((lastpos <= -2) && (X509at_get_attr_by_OBJ(x, obj, i) != -1))
+ return NULL;
+ at = X509at_get_attr(x, i);
+ if (lastpos <= -3 && (X509_ATTRIBUTE_count(at) != 1))
+ return NULL;
+ return X509_ATTRIBUTE_get0_data(at, type, 0, NULL);
+}
+
X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
int atrtype, const void *data, int len)
{