ASN1_NULL_NEW(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

✨ ASN1_NULL_NEW πŸ’…

ok so bestie, today we're learning about ASN1_NULL_new and ASN1_NULL_free β€” the AS.1 NULL value girlies. yes it's literally a value that means "nothing" and yes it has its own constructor. we love a low-effort icon πŸŽ€


🌸 SYNOPSIS 🌸

this whole thing lives in library libcrypto, so first things first, you gotta:

#include <openssl/asn1.h>

and then the two functions are:

ASN1_NULL *
ASN1_NULL_new(void);

void
ASN1_NULL_free(ASN1_NULL *val_in);

periodt. that's the whole API. she's simple, she's chic. ✨


πŸ’– DESCRIPTION πŸ’–

ASN1_NULL_new()

okay so this is the funny one. ASN1_NULL_new() returns a specific invalid pointer that represents the ASN.1 NULL value β€” which, fun fact, is the only possible value of the ASN.1 NULL type. like it's the only child and it's an invalid pointer, we stan a quirky main character πŸ‘‘

and listen: that pointer is different from a NULL pointer. i cannot stress this enough. it looks like a pointer, it smells like a pointer, but it is not your standard-issue NULL.

🚨 dereferencing it almost certainly results in a segmentation fault. like bestie do NOT. i'm begging. put it down. πŸ™ˆπŸ’€

the good news? this function does not allocate memory and cannot fail. zero malloc drama, zero error checking needed. it's giving effortless. πŸ’…

ASN1_NULL_free()

and now for the plot twist: ASN1_NULL_free() has no effect whatsoever. 😭

like, at all. in particular:

  • it ignores the val_in argument
  • it does not free any memory

so what's the vibe here? in normal use, application programs only pass the invalid pointer they got from ASN1_NULL_new() to this function. that's the intended path, that's the whole ritual 🫢

but here's the catch β€” even if a valid pointer is passed, that pointer does not become invalid. no, she stays valid. this function is just out here doing literally nothing and collecting a paycheck. truly iconique behaviour. πŸ’€βœ¨

one more thing πŸ¦‹

the ASN.1 NULL type is also represented by the V_ASN1_NULL type identifier constant. iykyk 🌈


πŸ”₯ SEE ALSO πŸ”₯

go read those next if you're feeling academically inclined, bestie πŸ“š


πŸ‘‘ STANDARDS πŸ‘‘

this one's certified by the big leagues:

ITU-T Recommendation X.208, also known as ISO/IEC 8824-1: Specification of Abstract Syntax Notation One (ASN.1), section 19: Notation for the null type

section 19 is the NULL section, appropriately. we love a self-explanatory girlie πŸŽ€


⭐ HISTORY ⭐

ASN1_NULL_new() and ASN1_NULL_free() first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7.

so they've been here longer than most of us have been alive, and they've been doing absolutely nothing the whole time. that's consistency bestie πŸ¦‹πŸ’œ


and that's the tea on ASN1_NULL! this page was brought to you by the Debian fam, dated June 8, 2025, filed under ASN1_NULL_NEW(3). slay, stay safe, and please don't dereference the invalid pointer πŸ’…βœ¨πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from