asn1_encode_tag(9)
π asn1_encode_tag(9) β the "add a tag for optional or explicit value" manual π
okay so bestie, welcome to the Kernel API Manual page for asn1_encode_tag(9). this one's all about tagging your data for ASN.1 encoding, and it's lowkey iconic. let's get into it β¨
β¨ NAME β¨
asn1_encode_tag β add a tag for optional or explicit value π·οΈ
π SYNOPSIS π
unsigned char * asn1_encode_tag (unsigned char *data , const unsigned
char *end_data , u32 tag , const unsigned char *string , int len );
π¦ ARGUMENTS π¦
dataβ pointer to place tag at πend_dataβ end of data pointer, points one beyond last usable byte indataπtagβ tag to be placed π·οΈstringβ the data to be tagged π¦lenβ the length of the data to be tagged π
πΈ DESCRIPTION πΈ
bestie, listen up: note this currently only handles short form tags < 31. that's the vibe check for now, ok? π
standard usage is to pass in a tag, string and length and the string will be ASN.1 encoded with tag and placed into data. if the encoding would put data past end_data then an error is returned, otherwise a pointer to a position one beyond the encoding is returned. slay that return value π
to encode in place pass a NULL string and -1 for len and the maximum allowable beginning and end of the data; all this will do is add the current maximum length and update the data pointer to the place where the tag contents should be placed is returned. the data should be copied in by the calling routine which should then repeat the prior statement but now with the known length. in order to avoid having to keep both before and after pointers, the repeat expects to be called with data pointing to where the first encode returned it and still NULL for string but the real length in len. no cap, that's the whole flow π«Ά
β οΈ heads up: short form tags only (< 31) rn β don't come for me, it's literally in the source π
π₯ SEE ALSO π₯
kernel file ./lib/asn1_encoder.c and friends:
asn1_encode_integer(9)asn1_encode_oid(9)asn1_encode_length(9)asn1_encode_octet_string(9)asn1_encode_sequence(9)asn1_encode_boolean(9)
go off, read them all, iykyk π
okay that's the whole page! this manual is from ./lib, version October 2026, and it's literally called asn1_encode_tag(9). periodt. πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms