ASN1_BIT_STRING_SET(3)

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

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 that bitstr is actually of the type V_ASN1_BIT_STRING nor, even if it is, that the data and len arguments 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:

  • bitnumber of 0 addresses the most significant bit in the first data byte of bitstr.
  • 7 addresses the least significant bit in the same byte.
  • 8 addresses 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() returns 1 on success or 0 if memory allocation fails or if data is NULL and len is -1 in the same call.
  • ASN1_BIT_STRING_set_bit() returns 1 on success or 0 if bitstr is NULL or if memory allocation fails.
  • ASN1_BIT_STRING_get_bit() returns 1 if the bit with the given bitnumber is set in the bitstr or 0 if bitstr is NULL, if bitnumber points beyond the last data byte in bitstr, 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