---
name: "libressl-ASN1_OBJECT_new"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-ASN1_OBJECT_new"
---

# libressl-ASN1\_OBJECT\_new(3)

ASN.1 object identifiers

## NAME

**ASN1\_OBJECT\_new**, **ASN1\_OBJECT\_create**, **ASN1\_OBJECT\_free** – ASN.1 object identifiers

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#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

**ASN1\_OBJECT\_new**() 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.

**ASN1\_OBJECT\_create**() 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 **ASN1\_OBJECT\_new**() or **ASN1\_OBJECT\_create**() directly.

**ASN1\_OBJECT\_free**() 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):

- ERR\_R\_MALLOC\_FAILURE "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:

- ERR\_R\_ASN1\_LIB "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.
