Scroll to navigation

ASN1_OBJECT_NEW(3) Library Functions Manual ASN1_OBJECT_NEW(3)

NAME

ASN1_OBJECT_new, ASN1_OBJECT_create, ASN1_OBJECT_freeASN.1 object identifiers

SYNOPSIS

#include <openssl/asn1.h>

ASN1_OBJECT *
ASN1_OBJECT_new(void);

ASN1_OBJECT *
ASN1_OBJECT_create(int nid, unsigned char *content, int len, const char *short_name, const char *long_name);

void
ASN1_OBJECT_free(ASN1_OBJECT *a);

DESCRIPTION

() allocates and initializes an empty ASN1_OBJECT object, representing an ASN.1 OBJECT IDENTIFIER. It can hold a short name, a long name, a numeric identifier (NID), and a sequence of integers identifying a node in the International Object Identifier tree as specified in ITU-T recommendation X.660. The new object is marked as dynamically allocated.

The ASN.1 object identifier type is also represented by the V_ASN1_OBJECT type identifier constant.

() allocates a new ASN1_OBJECT with the given nid, copies the len DER content octets, the short_name, and the long_name into it, and marks the new object and all data contained in it as dynamically allocated.

Application programs normally use utility functions like OBJ_nid2obj(3) rather than using () or ASN1_OBJECT_create() directly.

() has the following effects:

All data contained in a that is marked as dynamically allocated is freed, and the respective fields of a become empty. Contained data not marked as dynamically allocated remains intact.

If the object a itself is marked as dynamically allocated, it is freed. Otherwise, the pointer a remains valid.

If a is a NULL pointer or if neither the object itself nor any of its content is marked as dynamically allocated, no action occurs.

RETURN VALUES

ASN1_OBJECT_new() and ASN1_OBJECT_create() return a pointer to the new object or NULL if memory allocation fails,

ERRORS

After failure of ASN1_OBJECT_new() or ASN1_OBJECT_create(), the following diagnostic can be retrieved with ERR_get_error(3), ERR_GET_REASON(3), and ERR_reason_error_string(3):

"malloc failure"
Memory allocation failed.

After some cases of failure of ASN1_OBJECT_create(), the following diagnostic can be retrieved in addition to the above:

"ASN1 lib"
Memory allocation failed.

SEE ALSO

a2d_ASN1_OBJECT(3), ASN1_TYPE_get(3), d2i_ASN1_OBJECT(3), OBJ_create(3), OBJ_nid2obj(3)

STANDARDS

ITU-T Recommendation X.208, also known as ISO/IEC 8824-1: Specification of Abstract Syntax Notation One (ASN.1), section 28: Notation for the object identifier type

ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER), section 8.19: Encoding of an object identifier value

HISTORY

ASN1_OBJECT_new() and ASN1_OBJECT_free() first appeared in SSLeay 0.5.1 and ASN1_OBJECT_create() in SSLeay 0.8.0. These functions have been available since OpenBSD 2.4.

BUGS

The function ASN1_OBJECT_new() is not useful for any practical purpose because the library does not provide any function capable of adding data to an existing object. Consequently, if the application program creates an object with ASN1_OBJECT_new(), that object will always remain empty.

Similarly, if an nid of NID_undef is passed to ASN1_OBJECT_create(), or if NULL is passed for any of its pointer arguments, the returned object will permanently remain incomplete.

September 5, 2023 Linux 6.4.0-150600.23.25-default