---
name: "libressl-OBJ_create"
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-OBJ_create"
---

# libressl-OBJ\_create(3)

modify the table of ASN.1 object identifiers

## NAME

**OBJ\_new\_nid**, **OBJ\_create**, **OBJ\_create\_objects**, **OBJ\_cleanup** – modify the table of ASN.1 object identifiers

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/objects.h\>**

*int*\

**OBJ\_new\_nid**(*int increment*);

*int*\

**OBJ\_create**(*const char \*oid*, *const char \*sn*, *const char \*ln*);

*int*\

**OBJ\_create\_objects**(*BIO \*in\_bio*);

*void*\

**OBJ\_cleanup**(*void*);

## DESCRIPTION

**OBJ\_new\_nid**() returns the smallest currently unassigned ASN.1 numeric object identifier (NID) and reserves *increment* consecutive NIDs starting with it. Passing an argument of 1 is usually recommended. The return value can be assigned to a new object by passing it as the *nid* argument to ASN1\_OBJECT\_create(3).

**OBJ\_create**() adds an *ASN1\_OBJECT* to the internal table of ASN.1 object identifiers for use by OBJ\_nid2obj(3) and related functions. *oid* is the numerical form of the object, *sn* the short name and *ln* the long name. A new NID is automatically assigned using **OBJ\_new\_nid**().

**OBJ\_create\_objects**() reads text lines of the form

*oid*, *sn*, *ln*

from *in\_bio* and calls **OBJ\_create**(*oid*, *sn*, *ln*) for every line read. The three fields of the input lines are separated by one or more whitespace characters.

For the objects added to the internal table by **OBJ\_create**() and **OBJ\_create\_objects**(), all the data contained is marked as not dynamically allocated. Consequently, retrieving them with OBJ\_nid2obj(3) or a similar function and then calling ASN1\_OBJECT\_free(3) on the returned pointer will have no effect.

**OBJ\_cleanup**() resets the internal object table to its default state, removing and freeing all objects that were added with **OBJ\_create**(), or **OBJ\_create\_objects**().

## RETURN VALUES

**OBJ\_new\_nid**() returns the new NID.

**OBJ\_create**() returns the new NID or NID\_undef if *oid* is not a valid representation of an object identifier or if memory allocation fails.

**OBJ\_create\_objects**() returns the number of objects added.

In some cases of failure of **OBJ\_create**() and **OBJ\_create\_objects**(), the reason can be determined with ERR\_get\_error(3).

## EXAMPLES

Create a new NID and initialize an object from it:

```
int new_nid;
ASN1_OBJECT *obj;
new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
obj = OBJ_nid2obj(new_nid);
```

## SEE ALSO

ASN1\_OBJECT\_new(3), OBJ\_nid2obj(3)

## HISTORY

**OBJ\_new\_nid**(), and **OBJ\_cleanup**() first appeared in SSLeay 0.8.0 and **OBJ\_create**() in SSLeay 0.9.0. These functions have been available since OpenBSD 2.4.

## CAVEATS

**OBJ\_create**() tolerates NULL pointers being passed for the *sn* and/or *ln* arguments, in which case OBJ\_nid2sn(3) and OBJ\_sn2nid(3) and/or OBJ\_nid2ln(3) and OBJ\_ln2nid(3) will not work on the added object.

## BUGS

**OBJ\_new\_nid**() does not reserve any return value to indicate an error. Consequently, to avoid conflicting NID assignments and integer overflows, care must be taken to not pass negative, zero, or large arguments to **OBJ\_new\_nid**().

**OBJ\_create\_objects**() does not distinguish between end of file, I/O errors, temporary unavailability of data on a non-blocking BIO, invalid input syntax, and memory allocation failure. In all these cases, reading is aborted and the number of objects that were already added is returned.
