asn1_read_value_type(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

πŸŽ€ NAME πŸŽ€

asn1_read_value_type β€” it's an API function, bestie, from the libtasn1 manual, and yes we're gonna read a value AND get its type at the same time. main character behavior honestly πŸ’…


✨ SYNOPSIS ✨

#include <libtasn1.h>

int asn1_read_value_type(asn1_node_const root, const char * name, void *
ivalue, int * len, unsigned int * etype);

like. okay. look at that signature. she's gorgeous. 🫢


🌸 ARGUMENTS 🌸

  • asn1_node_const root β€” pointer to a structure. that's your entry point babes, the whole tree lives here.
  • const char * name β€” the name of the element inside a structure that you want to read. i.e. which lil guy inside the tree are we peeking at πŸ”
  • void * ivalue β€” vector that will contain the element's content. heads up: it must be a pointer to memory cells you already allocated (it may be NULL though, so no stress there).
  • int * len β€” number of bytes of *value: value[0]..value[len-1]. Initially holds the sizeof value. so like, you tell it how much room you got, and it tells you what it actually used.
  • unsigned int * etype β€” The type of the value read (ASN1_ETYPE). the receipts on what kind of thing you just got back ✨

πŸ’– DESCRIPTION πŸ’–

Returns the type and value of one element inside a structure. 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, it's not an error error, it's just... not there. she ghosted. πŸ’€)

The first element of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and so on. And if the root provided is a node to specific sequence element, then the keyword "?CURRENT" is also acceptable and indicates the current sequence element of this node. iykyk 🧚

Note that there can be valid values with length zero. In these case this function will succeed and len will be zero. so a zero is not a fail, bestie, it's just a zero. periodt.

πŸ”₯ INTEGER

VALUE will contain a two's complement form integer.

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

πŸ”₯ ENUMERATED

As INTEGER (but only with not negative numbers). so like, no negatives allowed here, sorry girlies βœ‹

πŸ”₯ BOOLEAN

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

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

πŸ”₯ 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.

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.

πŸ”₯ CHOICE

If NAME indicates a choice type, VALUE will specify the alternative selected. (choose your fighter πŸ’…)

πŸ”₯ ANY

If NAME indicates an any type, VALUE will indicate the DER encoding of the structure actually used.


πŸ’… RETURNS πŸ’…

  • ASN1_SUCCESS if value is returned β€” slay, we got it ✨
  • 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. (rude of you to not allocate enough but ok, she's telling you the size now πŸ™ˆ)

On the occasion that the stored data are of zero-length this function may return ASN1_SUCCESS even if the provided len is zero.


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.


🌈 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/

and that's the whole page bestie!! πŸ¦‹ this one's from libtasn1, version 4.21.0, and it lives under the name asn1_read_value_type(3) in the manual β€” go read it, go call it, go absolutely devour it. mwah πŸ’–

πŸ“¦ where this page comes from