OBJ_CREATE(3)
π OBJ_CREATE(3) β your fave ASN.1 object-table glow-up guide β¨
okay so bestie, this is a libcrypto page (from the OBJ_CREATE(3) part of the library functions manual) and it's literally all about fiddling with the table of ASN.1 object identifiers. ngl it's a little niche but it ate and you're gonna slay it π
β¨ SYNOPSIS β¨
library βlibcryptoβ
#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 πΈ
So here's the tea, one function at a time π
OBJ_new_nid() hands you the smallest ASN.1 numeric object identifier (NID) that's currently unassigned, and then reserves increment consecutive NIDs starting right there. Passing an argument of 1 is usually the recommended move, fr fr. You can then assign that return value to a brand new object by passing it as the nid argument to ASN1_OBJECT_create(3). iconic behavior honestly π¦
OBJ_create() adds an ASN1_OBJECT to the internal table of ASN.1 object identifiers so that OBJ_nid2obj(3) and its friends can actually find it. Here's the breakdown of the args:
oidβ the numerical form of the objectsnβ the short namelnβ the long name
A new NID gets automatically assigned via OBJ_new_nid(). no cap π
OBJ_create_objects() reads text lines that look like this:
oid sn ln
...from in_bio, and calls OBJ_create(oid, sn, ln) for every single line it reads. The three fields of each input line are separated by one or more whitespace characters. cute, right? π
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. So listen bestie, if you retrieve them with OBJ_nid2obj(3) or a similar function and then call ASN1_OBJECT_free(3) on the returned pointer β it will have no effect. literally nothing happens. the vibe check just passes right through π«Ά
OBJ_cleanup() resets the internal object table to its default state, removing and freeing all the objects that were added with OBJ_create() or OBJ_create_objects(). spring cleaning era πΈ
π RETURN VALUES π
OBJ_new_nid()β returns the new NID πOBJ_create()β returns the new NID, orNID_undefifoidisn't 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(), you can figure out the reason with ERR_get_error(3).
π§ EXAMPLES π§
Create a new NID and initialize an object from it β this is the moment, main character energy only:
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() showed up in SSLeay 0.9.0. These functions have been available since OpenBSD 2.4. vintage. retro. still slaying π₯
π CAVEATS π
OBJ_create() tolerates NULL pointers being passed for the sn and/or ln arguments β which sounds chill until you realize that in that case OBJ_nid2sn(3) and OBJ_sn2nid(3) and/or OBJ_nid2ln(3) and OBJ_ln2nid(3) will not work on the added object. so like, it won't crash on you, but it also won't help you π
π 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 toOBJ_new_nid(). this one's important bestie, don't sleep on it π
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. so it's giving "one error message for every problem" and honestly? not the serve π«
alright that's the whole page, go forth and manage your object identifier table like the icon you are π β¨
mwah π
β with love from the Debian edition, dated August 5, 2026 ππ¦
π¦ where this page comes from
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2017, 2021, 2023 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2002, 2006 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms