ASN1_STRING_NEW(3)
π
ASN1_STRING_NEW(3) β the ASN1_STRING allocation glow-up
okay so bestie, this is a page from the Library Functions Manual, and it's all about making and yeeting ASN1_STRING objects. it's giving very "i contain multitudes" energy, and honestly she does. β¨
β¨ NAME β¨
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 β allocate and free ASN1_STRING objects π
like, the whole friend group. they all do the same two things: make a thing, and free a thing. periodt.
πΈ SYNOPSIS πΈ
library βlibcryptoβ
#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 π¦
so the ASN1_STRING object is basically the main character of ASN.1 built-in types β she can represent a whole variety of them. she's got two things going on: a type and a value. iconic, versatile, no notes. π
all the *_new() functions allocate and initialize an empty ASN1_STRING object. and here's the tea on what type each one gets assigned, plus which ASN.1 type that actually represents π
ASN1_STRING_new()β OpenSSL typeV_ASN1_OCTET_STRING(the ASN.1 type column is blank for this one, she's just vibing as the generic base)ASN1_STRING_type_new()β OpenSSL type is whatever you pass in thetypeargument (again, no ASN.1 type listed β you're the one deciding, bestie)ASN1_OCTET_STRING_new()βV_ASN1_OCTET_STRING, representingOCTET STRINGASN1_BIT_STRING_new()βV_ASN1_BIT_STRING, representingBIT STRINGASN1_INTEGER_new()βV_ASN1_INTEGER, representingINTEGERASN1_ENUMERATED_new()βV_ASN1_ENUMERATED, representingENUMERATEDASN1_UTF8STRING_new()βV_ASN1_UTF8STRING, representingUTF8StringASN1_IA5STRING_new()βV_ASN1_IA5STRING, representingIA5StringASN1_UNIVERSALSTRING_new()βV_ASN1_UNIVERSALSTRING, representingUniversalStringASN1_BMPSTRING_new()βV_ASN1_BMPSTRING, representingBMPStringASN1_GENERALSTRING_new()βV_ASN1_GENERALSTRING, representingGeneralStringASN1_T61STRING_new()βV_ASN1_T61STRING, representingT61StringASN1_VISIBLESTRING_new()βV_ASN1_VISIBLESTRING, representingVisibleStringASN1_PRINTABLESTRING_new()βV_ASN1_PRINTABLESTRING, representingPrintableStringASN1_PRINTABLE_new()βV_ASN1_UNDEF(yep, undefined. she's mysterious β¨)DIRECTORYSTRING_new()βV_ASN1_UNDEF(also mysterious)DISPLAYTEXT_new()βV_ASN1_UNDEF(mystery squad, assemble)ASN1_GENERALIZEDTIME_new()βV_ASN1_GENERALIZEDTIME, representingGeneralizedTimeASN1_UTCTIME_new()βV_ASN1_UTCTIME, representingUTCTimeASN1_TIME_new()βV_ASN1_UNDEF, representingTIME
and for cleanup time π§Ή β all the *_free() functions free a, including any data contained in it. and if a is a NULL pointer, no action occurs. she simply doesn't react. no drama, no crash. π«Ά
π 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). ngl, always check β a NULL sneaking up on you is not the vibe. π
π 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)
the whole extended friend group, go say hi π¦
β HISTORY β
a little lore drop for you, because the backstory is lowkey fascinating π:
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(), andASN1_UTCTIME_free()first appeared in SSLeay 0.5.1.ASN1_STRING_new(),ASN1_STRING_type_new(), andASN1_STRING_free()first appeared in SSLeay 0.6.5.ASN1_UNIVERSALSTRING_new(),ASN1_UNIVERSALSTRING_free(),ASN1_GENERALSTRING_new(), andASN1_GENERALSTRING_free()first appeared in SSLeay 0.8.0.ASN1_BMPSTRING_new(),ASN1_BMPSTRING_free(),ASN1_GENERALIZEDTIME_new(), andASN1_GENERALIZEDTIME_free()first appeared in SSLeay 0.9.0.- all of these have been available since OpenBSD 2.4. β¨
and then the newer gen arrived:
ASN1_ENUMERATED_new(),ASN1_ENUMERATED_free(),ASN1_TIME_new(), andASN1_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(), andDISPLAYTEXT_free()first appeared in OpenSSL 0.9.3.- these have been available since OpenBSD 2.6. π
π BUGS π
okay bestie, warning time. π¨
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. π
fr fr β they're all the same girl in different outfits. don't let the cute typedef names fool you into thinking the compiler will catch your mistakes, because she will not. π
and that's the page, bestie! this one came from the Debian build, dated June 8, 2025 β so if you're citing it, that's the whole pedigree πβ¨ go forth and allocate responsibly π
π¦ 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 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms