libressl-X509_ATTRIBUTE_new3
Generic x.501 attribute
Usage
Crypto Library (libcrypto, -lcrypto)
#include <openssl/x509.h>
X509_ATTRIBUTE *
X509_ATTRIBUTE_new(void);
X509_ATTRIBUTE *
X509_ATTRIBUTE_create(int nid, int type, void *value);
X509_ATTRIBUTE *
X509_ATTRIBUTE_dup(X509_ATTRIBUTE *attr);
void
X509_ATTRIBUTE_free(X509_ATTRIBUTE *attr);
Overview
In the X.501 standard, an Attribute is the fundamental ASN.1 data type used to represent any kind of property of any kind of directory entry. In OpenSSL, very few objects use it directly, most notably the X509_REQ_INFO object used for PKCS#10 certification requests described in X509_REQ_new(3), the PKCS8_PRIV_KEY_INFO object used for PKCS#8 private key information described in PKCS8_PRIV_KEY_INFO_new(3), and the PKCS12_SAFEBAG container object described in PKCS12_SAFEBAG_new(3).
X509_ATTRIBUTE_new() allocates and initializes an empty X509_ATTRIBUTE object.
X509_ATTRIBUTE_create() allocates a new multi-valued X509_ATTRIBUTE object of the type nid and initializes its set of values to contain one new ASN.1 ANY object with the given value and type. The type usually is one of the V_ASN1_* constants defined in ⟨openssl/asn1.h⟩; it is stored without validating it. If the function succeeds, ownership of the value is transferred to the new X509_ATTRIBUTE object.
Be careful to not confuse the type of the attribute and the type of the value.
X509_ATTRIBUTE_dup() creates a deep copy of attr.
X509_ATTRIBUTE_free() frees attr.
Return values
X509_ATTRIBUTE_new(), X509_ATTRIBUTE_create(), and X509_ATTRIBUTE_dup() return the new X509_ATTRIBUTE object or NULL if an error occurs.
In particular, these functions fail if memory allocation fails. X509_ATTRIBUTE_create() also fails if OBJ_nid2obj(3) fails on nid.