asn1_bit_der(3)

πŸ“¦
version 4.21.0 Β· 5 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu resolute, ubuntu stonking

πŸ’– asn1_bit_der β€” the libtasn1 girlies' guide πŸ’–

okay so bestie, you're in libtasn1 land, section 3 of the manual, and today's main character is asn1_bit_der(3). yes it's an API function. yes it's giving crypto-adjacent. let's GO πŸ¦‹


✨ NAME ✨

asn1_bit_der β€” it's an API function, bestie. that's the whole name. short, iconic, no notes. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <libtasn1.h>

void asn1_bit_der(const unsigned char * str, int bit_len, unsigned char
* der, int * der_len);

like. the way it just sits there in <libtasn1.h> waiting for you to call it. periodt. πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

okay so every single one of these matters, don't skip, i'm watching πŸ‘€

  • const unsigned char * str β€” this is your BIT string. the raw material. the moment. 🌟
  • int bit_len β€” how many bits in STR are actually meaningful. like, the ones that count. the rest is just vibes (and padding, but mostly vibes). πŸ’«
  • unsigned char * der β€” the string that gets returned. your output. your little DER baby. 🍼
  • int * der_len β€” the number of meaningful bytes of DER, specifically der[0]..der[ans_len-1]. (yes it says ans_len, no we are not fixing it, it's canon, we respect the lore πŸ™ˆ)

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea: this function creates a length-value DER encoding for the input data, exactly as it would have been for a BIT STRING. the DER encoded data gets copied into der. that's it. that's the function. slay. ✨

IMPORTANT BESTIE: the BIT STRING tag is NOT included in the output. not there. absent. gone. if you were expecting a tag you're gonna have a bad time. 😭

and here's the lowkey unhinged part: this function does not return any value β€” not a status, not a count, nothing, it's a void and it's thriving β€” because it just expects that der_len will already contain enough bytes to store the string plus the DER encoding. it trusts you. do not betray that trust. 🫢

if you need to know how big that DER encoding actually is, you go get it from asn1_length_der(). go ask her. she knows. 🧚


Copyright Β© 2006-2025 Free Software Foundation, Inc..

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.

(translation: use it, share it, remix it, just leave the receipts attached. free of charge. iconic behaviour, honestly. πŸ’œ)


🌈 SEE ALSO 🌈

The full documentation for libtasn1 is maintained as a Texinfo manual. If the info and libtasn1 programs are properly installed at your site, the command

info libtasn1

should give you access to the complete manual. As an alternative you may obtain the manual from:

https://www.gnu.org/software/libtasn1/manual/

like, go read the whole thing, it's a vibe. iykyk. πŸ“šβœ¨


and that's the page, bestie!! this was libtasn1 version 4.21.0, dated the same, page asn1_bit_der(3) β€” tysm for reading, you ate that, no cap πŸ’…πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from