You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libowfat/scan/scan_asn1derlengthvalue.3

30 lines
1.3 KiB
Groff

.TH scan_asn1derlength 3
.SH NAME
scan_asn1derlengthvalue \- decode an unsigned integer from ASN.1 DER length encoding
.SH SYNTAX
.B #include <libowfat/scan.h>
size_t \fBscan_asn1derlengthvalue\fP(const char *\fIsrc\fR,size_t \fIlen\fR,unsigned long long *\fIdest\fR);
.SH DESCRIPTION
scan_asn1derlengthvalue decodes an unsigned integer in ASN.1 DER length encoding
from a memory area holding binary data. It writes the decode value in
\fIdest\fR and returns the number of bytes it read from \fIsrc\fR.
scan_asn1derlength never reads more than \fIlen\fR bytes from \fIsrc\fR. If the
sequence is longer than that, or the memory area contains an invalid
sequence, scan_asn1derlength returns 0 and does not touch \fIdest\fR.
The length of the longest spec-compliant ASN.1 DER length is 128 bytes,
but this implementation will return an error if the value does not fit
into the target integer type. In practice the largest sequence is
sizeof(*dest)+1.
This implementation will reject values that are not encoded in the
minimum amount of bytes.
If you need to decode the length value so you can parse actual ASN.1
tag/length/value structures, please consider using scan_asn1derlength
instead, as it will do additional checking for you.
.SH "SEE ALSO"
fmt_asn1derlength(3), scan_asn1derlengthvalue(3)