ASN1_STRING_NEW(3)

πŸ“¦
version 4.1.0 Β· 3 versions
, in opensuse-leap 16.0

πŸ’… ASN1_STRING_NEW(3) β€” Library Functions Manual ✨

okay bestie, so this is the page for ASN1_STRING_NEW(3) from the Library Functions Manual, and it's literally all about making and yeeting ASN.1 string objects πŸŽ€


🌸 NAME 🌸

So the whole girlie squad here is:

ASN1_STRING_new, ASN1_STRING_type_new, ASN1_STRING_free, ASN1_OCTET_STRING_new, ASN1_OCTET_STRING_free, ASN1_BIT_STRING_new, ASN1_BIT_STRING_free, ASN1_INTEGER_new, ASN1_INTEGER_free, ASN1_ENUMERATED_new, ASN1_ENUMERATED_free, ASN1_UTF8STRING_new, ASN1_UTF8STRING_free, ASN1_IA5STRING_new, ASN1_IA5STRING_free, ASN1_UNIVERSALSTRING_new, ASN1_UNIVERSALSTRING_free, ASN1_BMPSTRING_new, ASN1_BMPSTRING_free, ASN1_GENERALSTRING_new, ASN1_GENERALSTRING_free, ASN1_T61STRING_new, ASN1_T61STRING_free, ASN1_VISIBLESTRING_new, ASN1_VISIBLESTRING_free, ASN1_PRINTABLESTRING_new, ASN1_PRINTABLESTRING_free, ASN1_PRINTABLE_new, ASN1_PRINTABLE_free, DIRECTORYSTRING_new, DIRECTORYSTRING_free, DISPLAYTEXT_new, DISPLAYTEXT_free, ASN1_GENERALIZEDTIME_new, ASN1_GENERALIZEDTIME_free, ASN1_UTCTIME_new, ASN1_UTCTIME_free, ASN1_TIME_new, ASN1_TIME_free

and their whole collective vibe is: allocate and free ASN1_STRING objects 🫢


✨ SYNOPSIS ✨

#include <openssl/asn1.h>

ASN1_STRING *
ASN1_STRING_new(void);

ASN1_STRING *
ASN1_STRING_type_new(int type);

void
ASN1_STRING_free(ASN1_STRING *a);

ASN1_OCTET_STRING *
ASN1_OCTET_STRING_new(void);

void
ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a);

ASN1_BIT_STRING *
ASN1_BIT_STRING_new(void);

void
ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);

ASN1_INTEGER *
ASN1_INTEGER_new(void);

void
ASN1_INTEGER_free(ASN1_INTEGER *a);

ASN1_ENUMERATED *
ASN1_ENUMERATED_new(void);

void
ASN1_ENUMERATED_free(ASN1_ENUMERATED *a);

ASN1_UTF8STRING *
ASN1_UTF8STRING_new(void);

void
ASN1_UTF8STRING_free(ASN1_UTF8STRING *a);

ASN1_IA5STRING *
ASN1_IA5STRING_new(void);

void
ASN1_IA5STRING_free(ASN1_IA5STRING *a);

ASN1_UNIVERSALSTRING *
ASN1_UNIVERSALSTRING_new(void);

void
ASN1_UNIVERSALSTRING_free(ASN1_UNIVERSALSTRING *a);

ASN1_BMPSTRING *
ASN1_BMPSTRING_new(void);

void
ASN1_BMPSTRING_free(ASN1_BMPSTRING *a);

ASN1_GENERALSTRING *
ASN1_GENERALSTRING_new(void);

void
ASN1_GENERALSTRING_free(ASN1_GENERALSTRING *a);

ASN1_T61STRING *
ASN1_T61STRING_new(void);

void
ASN1_T61STRING_free(ASN1_T61STRING *a);

ASN1_VISIBLESTRING *
ASN1_VISIBLESTRING_new(void);

void
ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *a);

ASN1_PRINTABLESTRING *
ASN1_PRINTABLESTRING_new(void);

void
ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *a);

ASN1_STRING *
ASN1_PRINTABLE_new(void);

void
ASN1_PRINTABLE_free(ASN1_STRING *a);

ASN1_STRING *
DIRECTORYSTRING_new(void);

void
DIRECTORYSTRING_free(ASN1_STRING *a);

ASN1_STRING *
DISPLAYTEXT_new(void);

void
DISPLAYTEXT_free(ASN1_STRING *a);

ASN1_GENERALIZEDTIME *
ASN1_GENERALIZEDTIME_new(void);

void
ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *a);

ASN1_UTCTIME *
ASN1_UTCTIME_new(void);

void
ASN1_UTCTIME_free(ASN1_UTCTIME *a);

ASN1_TIME *
ASN1_TIME_new(void);

void
ASN1_TIME_free(ASN1_TIME *a);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the ASN1_STRING object is that versatile main-character type that can represent a whole variety of ASN.1 built-in types πŸ‘‘ it holds a type and a value, that's literally its whole thing.

Every single *_new() function allocates and initializes an empty ASN1_STRING object. no thoughts, head empty, freshly allocated πŸ’…

and here's the tea on which type gets assigned to the new object and which ASN.1 type it represents β€” the original page did this as a table, but we're doing it as a list because tables are not the vibe here:

  • ASN1_STRING_new() β†’ OpenSSL type V_ASN1_OCTET_STRING
  • ASN1_STRING_type_new() β†’ the type argument (you pick bestie, it's giving build-your-own)
  • ASN1_OCTET_STRING_new() β†’ V_ASN1_OCTET_STRING β†’ ASN.1 type OCTET STRING
  • ASN1_BIT_STRING_new() β†’ V_ASN1_BIT_STRING β†’ ASN.1 type BIT STRING
  • ASN1_INTEGER_new() β†’ V_ASN1_INTEGER β†’ ASN.1 type INTEGER
  • ASN1_ENUMERATED_new() β†’ V_ASN1_ENUMERATED β†’ ASN.1 type ENUMERATED
  • ASN1_UTF8STRING_new() β†’ V_ASN1_UTF8STRING β†’ ASN.1 type UTF8String
  • ASN1_IA5STRING_new() β†’ V_ASN1_IA5STRING β†’ ASN.1 type IA5String
  • ASN1_UNIVERSALSTRING_new() β†’ V_ASN1_UNIVERSALSTRING β†’ ASN.1 type UniversalString
  • ASN1_BMPSTRING_new() β†’ V_ASN1_BMPSTRING β†’ ASN.1 type BMPString
  • ASN1_GENERALSTRING_new() β†’ V_ASN1_GENERALSTRING β†’ ASN.1 type GeneralString
  • ASN1_T61STRING_new() β†’ V_ASN1_T61STRING β†’ ASN.1 type T61String
  • ASN1_VISIBLESTRING_new() β†’ V_ASN1_VISIBLESTRING β†’ ASN.1 type VisibleString
  • ASN1_PRINTABLESTRING_new() β†’ V_ASN1_PRINTABLESTRING β†’ ASN.1 type PrintableString
  • ASN1_PRINTABLE_new() β†’ V_ASN1_UNDEF (no ASN.1 type listed, it's mysterious like that πŸ™ˆ)
  • DIRECTORYSTRING_new() β†’ V_ASN1_UNDEF (same, undefined energy)
  • DISPLAYTEXT_new() β†’ V_ASN1_UNDEF (also undefined, we love a mystery)
  • ASN1_GENERALIZEDTIME_new() β†’ V_ASN1_GENERALIZEDTIME β†’ ASN.1 type GeneralizedTime
  • ASN1_UTCTIME_new() β†’ V_ASN1_UTCTIME β†’ ASN.1 type UTCTime
  • ASN1_TIME_new() β†’ V_ASN1_UNDEF β†’ ASN.1 type TIME

and every *_free() function frees a including any data contained in it β€” like, full cleanup, no leftovers 🧹

little safety note bestie: if a is a NULL pointer, no action occurs. it just politely does nothing 😌

πŸ’– RETURN VALUES πŸ’–

All the *_new() functions return the new ASN1_STRING object if successful πŸŽ‰

otherwise NULL is returned, and you can grab an error code with ERR_get_error(3) πŸ”₯


🌈 SEE ALSO 🌈

a2i_ipadd(3), ASN1_BIT_STRING_set(3), ASN1_INTEGER_get(3), ASN1_item_pack(3), ASN1_mbstring_copy(3), ASN1_PRINTABLE_type(3), ASN1_STRING_length(3), ASN1_STRING_print_ex(3), ASN1_TIME_set(3), ASN1_TYPE_get(3), ASN1_UNIVERSALSTRING_to_string(3), d2i_ASN1_OBJECT(3), d2i_ASN1_OCTET_STRING(3), i2a_ASN1_STRING(3), s2i_ASN1_INTEGER(3), X509_cmp_time(3), X509_EXTENSION_get_object(3), X509_get_ext_by_OBJ(3), X509_NAME_ENTRY_get_object(3)


πŸŽ€ HISTORY πŸŽ€

story time, gather round πŸ“–

ASN1_OCTET_STRING_new(), ASN1_OCTET_STRING_free(), ASN1_BIT_STRING_new(), ASN1_BIT_STRING_free(), ASN1_INTEGER_new(), ASN1_INTEGER_free(), ASN1_IA5STRING_new(), ASN1_IA5STRING_free(), ASN1_T61STRING_new(), ASN1_T61STRING_free(), ASN1_PRINTABLESTRING_new(), ASN1_PRINTABLESTRING_free(), ASN1_PRINTABLE_new(), ASN1_PRINTABLE_free(), ASN1_UTCTIME_new(), and ASN1_UTCTIME_free() first appeared in SSLeay 0.5.1.

then ASN1_STRING_new(), ASN1_STRING_type_new(), and ASN1_STRING_free() first appeared in SSLeay 0.6.5.

then ASN1_UNIVERSALSTRING_new(), ASN1_UNIVERSALSTRING_free(), ASN1_GENERALSTRING_new(), and ASN1_GENERALSTRING_free() first appeared in SSLeay 0.8.0.

and ASN1_BMPSTRING_new(), ASN1_BMPSTRING_free(), ASN1_GENERALIZEDTIME_new(), and ASN1_GENERALIZEDTIME_free() first appeared in SSLeay 0.9.0 ✨

all these functions have been available since OpenBSD 2.4 πŸ’œ

okay and then, newer era:

ASN1_ENUMERATED_new(), ASN1_ENUMERATED_free(), ASN1_TIME_new(), and ASN1_TIME_free() first appeared in OpenSSL 0.9.2b.

ASN1_UTF8STRING_new(), ASN1_UTF8STRING_free(), ASN1_VISIBLESTRING_new(), ASN1_VISIBLESTRING_free(), DIRECTORYSTRING_new(), DIRECTORYSTRING_free(), DISPLAYTEXT_new(), and DISPLAYTEXT_free() first appeared in OpenSSL 0.9.3.

these functions have been available since OpenBSD 2.6 🌸


πŸ’€ BUGS πŸ’€

ngl this is the part that hurts 😭

ASN1_OCTET_STRING, ASN1_BIT_STRING, ASN1_INTEGER, ASN1_ENUMERATED, ASN1_UTF8STRING, ASN1_IA5STRING, ASN1_UNIVERSALSTRING, ASN1_BMPSTRING, ASN1_GENERALSTRING, ASN1_T61STRING, ASN1_VISIBLESTRING, ASN1_PRINTABLESTRING, ASN1_GENERALIZEDTIME, ASN1_UTCTIME, and ASN1_TIME are merely typedef aliases of ASN1_STRING and provide no type safety whatsoever.

so yeah. zero type safety. absolutely none. the compiler will not save you, bestie β€” it's giving "we're all just ASN1_STRING underneath" πŸ™ˆ

and that's the whole page fr fr πŸ’… big mwah to Debian, dated December 27, 2024 β€” that's where this icon came from, and honestly? iconic. πŸ«Άβœ¨πŸŽ€

πŸ“¦ where this page comes from