— modify the table of ASN.1
OBJ_create(const char *oid,
const char *sn, const char
extern int obj_cleanup_defer;
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) and by passing the resulting object to
adds a copy of the object to the internal table of
ASN.1 object identifiers for use by
OBJ_nid2obj(3) and related functions.
provides a simpler way to add a new object to the internal table.
oid is the numerical form of the object,
sn the short name and ln the
long name. A new NID is automatically assigned using
reads text lines of the form
from in_bio and calls
sn, ln) for every line read. The
three fields of the input lines are separated by one or more whitespace
For all three functions, the objects added to the internal table and all the data contained in them 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.
The global variable
obj_cleanup_defer controls the behaviour of
If obj_cleanup_defer has
the default value of 0,
resets the internal object table to its default state, removing and freeing
all objects that were added with
OBJ_cleanup() only sets
obj_cleanup_defer to 2, which defers the cleanup of
the internal object table to the next call of
EVP_cleanup(3) has no effect on the internal object table. Only if
obj_cleanup_defer is 2, it resets
obj_cleanup_defer to 0 and calls
which then resets the table to its default state.
sets obj_cleanup_defer to 1 unless
nid is a built-in numeric identifier, but it has no
effect if obj_cleanup_defer already differs from 0.
This function is called internally by various functions in the EVP library,
in particular by subroutines of
To reliably reset the internal object table no
matter what the current state may be, an application program needs to call
and EVP_cleanup(3), in this order. The opposite order will usually not
OBJ_new_nid() returns the new NID.
OBJ_add_object() returns the NID of the
added object or
no object was added because the object argument was
NULL, did not contain an NID, or memory allocation
OBJ_create() returns the new NID or
NID_undef if oid is not a
valid representation of an object identifier or if memory allocation
OBJ_create_objects() returns the number of
In some cases of failure of
OBJ_create_objects(), the reason can be determined
Create a new NID and initialize an object from it:
int new_nid; ASN1_OBJECT *obj; new_nid = OBJ_create("220.127.116.11", "NewOID", "New Object Identifier"); obj = OBJ_nid2obj(new_nid);
ASN1_OBJECT_new(3), EVP_cleanup(3), OBJ_NAME_add(3), OBJ_nid2obj(3)
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.
check_defer() first appeared in OpenSSL 1.0.0 and
have been available since OpenBSD 4.9.
OBJ_add_object() indicates success even
after adding an incomplete object that was created with
ASN1_OBJECT_create(3) but lacks a short name, a long name, or
NULL pointers being passed for the
sn and/or ln arguments, in which
case OBJ_nid2sn(3) and
OBJ_ln2nid(3) will not work on the added object, respectively.
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_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.