]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/x509/x_attrib.c
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "internal/cryptlib.h"
12 #include <openssl/objects.h>
13 #include <openssl/asn1t.h>
14 #include <openssl/x509.h>
15 #include "x509_local.h"
17 DEFINE_STACK_OF(ASN1_TYPE
)
20 * X509_ATTRIBUTE: this has the following form:
22 * typedef struct x509_attributes_st
24 * ASN1_OBJECT *object;
25 * STACK_OF(ASN1_TYPE) *set;
30 ASN1_SEQUENCE(X509_ATTRIBUTE
) = {
31 ASN1_SIMPLE(X509_ATTRIBUTE
, object
, ASN1_OBJECT
),
32 ASN1_SET_OF(X509_ATTRIBUTE
, set
, ASN1_ANY
)
33 } ASN1_SEQUENCE_END(X509_ATTRIBUTE
)
35 IMPLEMENT_ASN1_FUNCTIONS(X509_ATTRIBUTE
)
36 IMPLEMENT_ASN1_DUP_FUNCTION(X509_ATTRIBUTE
)
38 X509_ATTRIBUTE
*X509_ATTRIBUTE_create(int nid
, int atrtype
, void *value
)
40 X509_ATTRIBUTE
*ret
= NULL
;
41 ASN1_TYPE
*val
= NULL
;
43 if ((ret
= X509_ATTRIBUTE_new()) == NULL
)
45 ret
->object
= OBJ_nid2obj(nid
);
46 if ((val
= ASN1_TYPE_new()) == NULL
)
48 if (!sk_ASN1_TYPE_push(ret
->set
, val
))
51 ASN1_TYPE_set(val
, atrtype
, value
);
54 X509_ATTRIBUTE_free(ret
);