| 1 |
// Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
#include <openssl/asn1.h> |
| 5 |
#include <openssl/asn1t.h> |
| 6 |
#include <openssl/obj.h> |
| 7 |
#include <openssl/x509.h> |
| 8 |
|
| 9 |
#include "internal.h" |
| 10 |
|
| 11 |
|
| 12 |
ASN1_SEQUENCE(X509_ATTRIBUTE) = { |
| 13 |
ASN1_SIMPLE(X509_ATTRIBUTE, object, ASN1_OBJECT), |
| 14 |
ASN1_SET_OF(X509_ATTRIBUTE, set, ASN1_ANY), |
| 15 |
} ASN1_SEQUENCE_END(X509_ATTRIBUTE) |
| 16 |
|
| 17 |
IMPLEMENT_ASN1_FUNCTIONS_const(X509_ATTRIBUTE) |
| 18 |
IMPLEMENT_ASN1_DUP_FUNCTION_const(X509_ATTRIBUTE) |
| 19 |
|
| 20 |
X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int attrtype, void *value) { |
| 21 |
ASN1_OBJECT *obj = OBJ_nid2obj(nid); |
| 22 |
if (obj == NULL) { |
| 23 |
return NULL; |
| 24 |
} |
| 25 |
|
| 26 |
X509_ATTRIBUTE *ret = X509_ATTRIBUTE_new(); |
| 27 |
ASN1_TYPE *val = ASN1_TYPE_new(); |
| 28 |
if (ret == NULL || val == NULL) { |
| 29 |
goto err; |
| 30 |
} |
| 31 |
|
| 32 |
ret->object = obj; |
| 33 |
if (!sk_ASN1_TYPE_push(ret->set, val)) { |
| 34 |
goto err; |
| 35 |
} |
| 36 |
|
| 37 |
ASN1_TYPE_set(val, attrtype, value); |
| 38 |
return ret; |
| 39 |
|
| 40 |
err: |
| 41 |
X509_ATTRIBUTE_free(ret); |
| 42 |
ASN1_TYPE_free(val); |
| 43 |
return NULL; |
| 44 |
} |