OBJ_CREATE(3)

πŸ“¦
version 4.4.0 Β· 2 versions
, in arch rolling

πŸ’… 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 object
  • sn β€” the short name
  • ln β€” 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, or NID_undef if oid isn'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 to OBJ_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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms