ASN1_OBJECT_NEW(3)
β¨ ASN1_OBJECT_NEW(3) β¨
okay so bestie, this is a page from the libcrypto Library Functions Manual and we're talking about ASN.1 object identifiers today. stay with me, it's actually so good π
π NAME π
ASN1_OBJECT_new, ASN1_OBJECT_create, ASN1_OBJECT_free β literally the ASN.1 object identifier girlies π¦
πΈ SYNOPSIS πΈ
#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);
this whole thing lives in the libcrypto library, just so you know π
π DESCRIPTION π
π«Ά ASN1_OBJECT_new()
bestie, ASN1_OBJECT_new() allocates and initializes an empty ASN1_OBJECT object β and that thing is representing an ASN.1 OBJECT IDENTIFIER. it's giving blank canvas energy β¨
so what can it even hold? a whole little squad of stuff:
- a short name
- a long name
- a numeric identifier (aka a NID)
- a sequence of integers that identifies a node in the International Object Identifier tree, as specified in ITU-T recommendation X.660 π³
and the new object? marked as dynamically allocated. periodt.
also like, the ASN.1 object identifier type is also represented by the V_ASN1_OBJECT type identifier constant. two names, one icon π
π§ ASN1_OBJECT_create()
this one 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 then marks the new object and all data contained in it as dynamically allocated. it's a full package deal, no cap π
ngl, real talk: application programs normally use utility functions likeOBJ_nid2obj(3)rather than usingASN1_OBJECT_new()orASN1_OBJECT_create()directly. iykyk.
π ASN1_OBJECT_free()
okay so this one has a few effects, and you gotta know all of them:
- all data contained in
athat is marked as dynamically allocated gets freed, and the respective fields ofabecome empty. anything contained that is not marked as dynamically allocated stays intact, untouched, living its truth π - if the object
aitself is marked as dynamically allocated, it is freed. otherwise, the pointeraremains valid β it survives, main character energy π - if
ais aNULLpointer, or if neither the object itself nor any of its content is marked as dynamically allocated, then nothing happens. no action, no drama π
β RETURN VALUES β
ASN1_OBJECT_new() and ASN1_OBJECT_create() return a pointer to the new object β or NULL if memory allocation fails (π rude but okay).
π₯ ERRORS π₯
after a failure of ASN1_OBJECT_new() or ASN1_OBJECT_create(), you can pull the following diagnostic with ERR_get_error(3), ERR_GET_REASON(3), and ERR_reason_error_string(3):
ERR_R_MALLOC_FAILURE"malloc failure"β memory allocation failed. that's it, that's the whole vibe π
and after some cases of failure of ASN1_OBJECT_create(), you can retrieve this one in addition to the above:
ERR_R_ASN1_LIB"ASN1 lib"β memory allocation failed. (yes bestie, same description, that's not a typo on my end π«Ά)
π¦ SEE ALSO π¦
a2d_ASN1_OBJECT(3), ASN1_TYPE_get(3), d2i_ASN1_OBJECT(3), OBJ_create(3), OBJ_nid2obj(3)
the whole friend group, go read them π
πΈ 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
standards queen behavior, honestly π
π HISTORY π
ASN1_OBJECT_new() and ASN1_OBJECT_free() first appeared in SSLeay 0.5.1, and ASN1_OBJECT_create() showed up in SSLeay 0.8.0. these functions have been available since OpenBSD 2.4. literal elders, we respect them π«‘
π BUGS π
okay so this is the messy part, listen up π
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. so if your application program creates an object with ASN1_OBJECT_new(), that object will always remain empty. forever. an empty vibe. π
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. permanently. incomplete. don't do it bestie π
and that's the page! π this one came from Debian, dated June 8, 2025 β mwah, thanks for reading, love u, bye π«Άβ¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- 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. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms