asn1_read_value(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_read_value β€” the libtasn1 glow-up πŸ’–

okay bestie, welcome to the libtasn1 corner of the group chat 🫢 this one's asn1_read_value(3), and it is literally the function that reaches into a structure and hands you back the value you asked for. no cap. let's get into it ✨


✨ NAME ✨

asn1_read_value β€” API function πŸ’… that's it, that's the name, she's serving simplicity.


🌸 SYNOPSIS 🌸

#include <libtasn1.h>

int asn1_read_value(asn1_node_const root, const char * name, void *
ivalue, int * len);

look at that signature. iconic. no notes. πŸ’œ


πŸŽ€ ARGUMENTS πŸŽ€

  • asn1_node_const root β€” pointer to a structure. yeah. she points at the structure. main character energy fr fr.
  • const char * name β€” the name of the element inside a structure that you want to read. tell her which element, she'll go get it πŸ¦‹
  • void * ivalue β€” vector that will contain the element's content. it must be a pointer to memory cells you already allocated (and yes, it may be NULL πŸ™ˆ). so like, have your memory ready before you come knocking.
  • int * len β€” number of bytes of *value: value[0]..value[len-1]. Initially it holds the sizeof value. so you tell her how much room you've got, she tells you how much she actually used πŸ’…

🌈 DESCRIPTION 🌈

Returns the value of one element inside a structure. that's the whole vibe. she reads, you receive, everyone's happy πŸ’–

If an element is OPTIONAL and this returns ASN1_ELEMENT_NOT_FOUND, it means that this element wasn't present in the der encoding that created the structure. so like, not a bug, not a flop β€” it just genuinely wasn't there, bestie 😭

The first element of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and so on. counting from one, because that's just how she is. If the root provided is a node to a specific sequence element, then the keyword "?CURRENT" is also acceptable and indicates the current sequence element of this node. periodt. πŸ‘‘

note bestie: there can be valid values with length zero. In these cases this function will succeed and len will be zero. so zero is not an error, zero is just a skinny legend. don't panic 🧚

⭐ INTEGER ⭐

VALUE will contain a two's complement form integer.

integer=-1  -> value[0]=0xFF , len=1.
integer=1   -> value[0]=0x01 , len=1.

two's complement representation, exactly as written, no editorialising from me πŸ’€


🌸 ENUMERATED 🌸

As INTEGER (but only with not negative numbers). so same energy, but no negativity allowed in this house πŸ’…


πŸ¦‹ BOOLEAN πŸ¦‹

VALUE will be the null terminated string "TRUE" or "FALSE" and LEN=5 or LEN=6. yes, the string. yes, actually. iykyk.

OBJECT IDENTIFIER: VALUE will be a null terminated string with each number separated by a dot (i.e. "1.2.3.543.1").

LEN = strlen(VALUE)+1

(it lives right here under the BOOLEAN heading, and honestly? she contains multitudes. we respect the layout πŸŽ€)


πŸ’œ UTCTIME πŸ’œ

VALUE will be a null terminated string in one of these formats: "YYMMDDhhmmss+hh'mm'" or "YYMMDDhhmmss-hh'mm'".

LEN=strlen(VALUE)+1

🌈 GENERALIZEDTIME 🌈

VALUE will be a null terminated string in the same format used to set the value. consistent queen ✨

OCTET STRING: VALUE will contain the octet string and LEN will be the number of octets.


πŸŽ€ GENERALSTRING πŸŽ€

VALUE will contain the generalstring and LEN will be the number of octets.

BIT STRING: VALUE will contain the bit string organized by bytes and LEN will be the number of bits. bits, bestie, not bytes. do not mix them up, i am begging πŸ™ˆ


πŸ‘‘ CHOICE πŸ‘‘

If NAME indicates a choice type, VALUE will specify the alternative selected. she picked one. she's telling you which. slay πŸ’…


πŸ”₯ ANY πŸ”₯

If NAME indicates an any type, VALUE will indicate the DER encoding of the structure actually used. the real one. the one that actually showed up. no cap. 🌟


πŸ’– RETURNS πŸ’–

  • ASN1_SUCCESS if value is returned πŸŽ‰
  • ASN1_ELEMENT_NOT_FOUND if name is not a valid element 😭
  • ASN1_VALUE_NOT_FOUND if there isn't any value for the element selected πŸ’€
  • ASN1_MEM_ERROR if The value vector isn't big enough to store the result, and in this case len will contain the number of bytes needed. so she's not just rejecting you, she's telling you exactly how much room to come back with. growth mindset 🫢
On the occasion that the stored data are of zero-length this function may return ASN1_SUCCESS even if the provided len is zero. zero-length data, zero-length len, still a success. that's just the rules 🧚

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. generous, iconic, no notes πŸ’œ


πŸ¦‹ 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/

go read the whole thing, bestie, it's giving ✨ comprehensive ✨


and that's the page!! this one shipped from libtasn1, version 4.21.0, and it's dated asn1_read_value(3) β€” so yeah, that's the source, the version and the date, all wrapped up in a little bow for you πŸŽ€πŸ’– mwah, go read some values, you've got this πŸ‘‘

πŸ“¦ where this page comes from