asn1_read_value(3)
π 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 beNULLπ). 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 thesizeofvalue. 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_SUCCESSif value is returned πASN1_ELEMENT_NOT_FOUNDifnameis not a valid element πASN1_VALUE_NOT_FOUNDif there isn't any value for the element selected πASN1_MEM_ERRORif The value vector isn't big enough to store the result, and in this caselenwill 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 returnASN1_SUCCESSeven if the providedlenis zero. zero-length data, zero-length len, still a success. that's just the rules π§
πΈ COPYRIGHT πΈ
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
- alpine 3.22: libtasn1-doc 4.21.0-r0 Β· LGPL-2.1-or-later
- alpine 3.23: libtasn1-doc 4.21.0-r0 Β· LGPL-2.1-or-later
- alpine 3.24: libtasn1-doc 4.21.0-r0 Β· LGPL-2.1-or-later
- arch rolling: libtasn1 4.21.0-1 Β· GPL-3.0-or-later AND LGPL-2.1-or-later AND GFDL-1.3-or-later
- fedora 43: libtasn1-devel 4.21.0-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: libtasn1-devel 4.21.0-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: libtasn1-devel 4.21.0-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: libtasn1-devel 4.21.0-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libtasn1-devel 4.21.0-160000.1.1 Β· GFDL-1.3-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libtasn1-devel 4.21.0-160000.1.1 Β· GFDL-1.3-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libtasn1-devel 4.21.0-160000.1.1 Β· GFDL-1.3-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libtasn1-devel 4.21.0-160000.1.1 Β· GFDL-1.3-or-later AND LGPL-2.1-or-later
- ubuntu resolute: libtasn1-6-dev 4.21.0-2
- ubuntu stonking: libtasn1-6-dev 4.21.0-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms