]>
Commit | Line | Data |
---|---|---|
b1322259 RS |
1 | /* |
2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | |
d02b48c6 | 3 | * |
3e4b43b9 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
b1322259 RS |
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 | |
d02b48c6 RE |
8 | */ |
9 | ||
10 | #include <stdio.h> | |
b39fc560 | 11 | #include "internal/cryptlib.h" |
ec577822 | 12 | #include <openssl/objects.h> |
9d6b1ce6 | 13 | #include <openssl/asn1t.h> |
f0e8ae72 | 14 | #include <openssl/x509.h> |
706457b7 | 15 | #include "x509_local.h" |
d02b48c6 | 16 | |
1d97c843 TH |
17 | /*- |
18 | * X509_ATTRIBUTE: this has the following form: | |
9d6b1ce6 DSH |
19 | * |
20 | * typedef struct x509_attributes_st | |
0f113f3e MC |
21 | * { |
22 | * ASN1_OBJECT *object; | |
e20b5727 | 23 | * STACK_OF(ASN1_TYPE) *set; |
0f113f3e | 24 | * } X509_ATTRIBUTE; |
9d6b1ce6 | 25 | * |
9d6b1ce6 | 26 | */ |
d02b48c6 | 27 | |
9d6b1ce6 | 28 | ASN1_SEQUENCE(X509_ATTRIBUTE) = { |
0f113f3e | 29 | ASN1_SIMPLE(X509_ATTRIBUTE, object, ASN1_OBJECT), |
e20b5727 | 30 | ASN1_SET_OF(X509_ATTRIBUTE, set, ASN1_ANY) |
d339187b | 31 | } ASN1_SEQUENCE_END(X509_ATTRIBUTE) |
d02b48c6 | 32 | |
9d6b1ce6 | 33 | IMPLEMENT_ASN1_FUNCTIONS(X509_ATTRIBUTE) |
1241126a | 34 | IMPLEMENT_ASN1_DUP_FUNCTION(X509_ATTRIBUTE) |
d02b48c6 | 35 | |
c8b41850 | 36 | X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value) |
0f113f3e MC |
37 | { |
38 | X509_ATTRIBUTE *ret = NULL; | |
39 | ASN1_TYPE *val = NULL; | |
dfeab068 | 40 | |
0f113f3e | 41 | if ((ret = X509_ATTRIBUTE_new()) == NULL) |
26a7d938 | 42 | return NULL; |
0f113f3e | 43 | ret->object = OBJ_nid2obj(nid); |
0f113f3e MC |
44 | if ((val = ASN1_TYPE_new()) == NULL) |
45 | goto err; | |
e20b5727 | 46 | if (!sk_ASN1_TYPE_push(ret->set, val)) |
0f113f3e | 47 | goto err; |
dfeab068 | 48 | |
0f113f3e | 49 | ASN1_TYPE_set(val, atrtype, value); |
26a7d938 | 50 | return ret; |
0f113f3e | 51 | err: |
222561fe | 52 | X509_ATTRIBUTE_free(ret); |
2ace7450 | 53 | ASN1_TYPE_free(val); |
26a7d938 | 54 | return NULL; |
0f113f3e | 55 | } |