ASN1_BIT_STRING_SET(3)
okay so bestie, welcome to the ASN1_BIT_STRING_SET(3) page from the Library Functions Manual β it's giving ASN.1 bit-string accessor realness, and we're gonna get through it together π
β¨
π NAME π
ASN1_BIT_STRING_set, ASN1_BIT_STRING_set_bit, ASN1_BIT_STRING_get_bit β ASN.1 BIT STRING accessors. That's the whole squad, and yes they're all about poking at BIT STRINGs π¦
πΈ SYNOPSIS πΈ
#include <openssl/asn1.h>
int
ASN1_BIT_STRING_set(ASN1_BIT_STRING *bitstr, unsigned char *data,
int len);
int
ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *bitstr, int bitnumber,
int set);
int
ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *bitstr, int bitnumber);
π DESCRIPTION π
ASN1_BIT_STRING_set() sets the length attribute of bitstr to len and copies that number of bytes from data into bitstr, overwriting any previous data β and it does this by merely calling ASN1_STRING_set(3). That's it. That's the whole move β¨
Important vibe check: this function does no validation whatsoever. In particular, it neither checks thatbitstris actually of the typeV_ASN1_BIT_STRINGnor, even if it is, that thedataandlenarguments make sense for this particular bit string. So yeah, it trusts you. Fully. No cap π
If the set argument is non-zero, ASN1_BIT_STRING_set_bit() sets the bit with the given bitnumber in the bitstr; otherwise, it clears that bit. And the bit-numbering lore is:
bitnumberof0addresses the most significant bit in the first data byte ofbitstr.7addresses the least significant bit in the same byte.8addresses the most significant bit in the second data byte, and so on.
If setting a bit is requested beyond the last existing data byte, additional bytes are added to the bitstr as needed. After clearing a bit, any trailing NUL bytes are removed from the bitstr. Cleanup slay π§
ASN1_BIT_STRING_get_bit() checks that the bit with the given bitnumber is set in bitstr. Iconic little peek behavior π
β RETURN VALUES β
ASN1_BIT_STRING_set()returns1on success or0if memory allocation fails or ifdataisNULLandlenis-1in the same call.ASN1_BIT_STRING_set_bit()returns1on success or0ifbitstrisNULLor if memory allocation fails.ASN1_BIT_STRING_get_bit()returns1if the bit with the givenbitnumberis set in thebitstror0ifbitstrisNULL, ifbitnumberpoints beyond the last data byte inbitstr, or if the requested bit is not set.
π¦ SEE ALSO π¦
π HISTORY π
ASN1_BIT_STRING_set() first appeared in SSLeay 0.6.5.
ASN1_BIT_STRING_set_bit() and ASN1_BIT_STRING_get_bit() first appeared in SSLeay 0.9.0.
These functions have been available since OpenBSD 2.4. Vintage but still main character energy π
and that's the page, bestie π«Ά the footer says source/version Debian, dated December 24, 2024, all under the ASN1_BIT_STRING_SET(3) title β periodt π
π
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· 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