ASN1_PRINTABLE_TYPE(3)
π ASN1_PRINTABLE_TYPE(3) π
okay so bestie, this is a page from the Library Functions Manual (yes the section 3 girlies, we love a library function) β and it's all about ASN1_PRINTABLE_type, which is lowkey just a little detective that looks at your string and goes "hmm, what kind of string are you?" π΅οΈββοΈβ¨
β¨ SYNOPSIS β¨
you pull it out of libcrypto, and it looks like this:
#include <openssl/asn1.h>
int
ASN1_PRINTABLE_type(const unsigned char *string, int len);
that's it. that's the whole vibe check. π
πΈ DESCRIPTION πΈ
So ASN1_PRINTABLE_type() assumes your string is made of single-byte characters (no fancy multi-byte nonsense, we're being strict here) and then it classifies it based on which kinds of characters show up in it. π¦
About that len, tho:
- if
lenis greater than 0, it inspects at mostlencharacters β like, it will literally not look further than that, respectfully π - otherwise (
lenis 0 or less), yourstringneeds to be NUL-terminated, no cap, that's the deal
π RETURN VALUES π
this is the part where it tells you who it thinks you are. three possible answers, and the order genuinely matters:
- if your string contains a character outside the ascii(7) range, it returns
V_ASN1_T61STRINGπ - otherwise, if it contains a character that is neither a letter nor a digit nor the space character (
' ', ASCII0x20) nor the apostrophe quote ('\'', ASCII0x27) nor contained in the set"()+,-./:=?"β then it returnsV_ASN1_IA5STRINGπ - otherwise β including if
stringis aNULLpointer or points to an empty string β it returnsV_ASN1_PRINTABLESTRINGπ
so yes, the coolest answer is also the fallback. main character energy fr fr. π
π«Ά SEE ALSO π«Ά
go read these next, they're iconic:
π§ HISTORY π§
ASN1_PRINTABLE_type() first appeared in SSLeay 0.4.5d, has been part of the public API since SSLeay 0.5.1, and has been available since OpenBSD 2.4. so she's been out here slaying since before most of us were born, periodt. β
β οΈ CAVEATS β οΈ
ngl this one's important: the ASN.1 notion of what constitutes aPrintableStringis more restrictive than what the C library functionisprint(3)considers printable. so don't go assumingisprint(3)saying "yeah that's printable" means ASN.1 agrees, because she does not. π
and that's the whole page, bestie π β brought to you by the Debian girlies, dated June 8, 2025, in manual section 3. now go classify some strings, you absolute icon ππ¦π
π¦ 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) 2021 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