module Netasn1:sig
..end
exception Out_of_range
exception Parse_error of int
module Type_name:sig
..end
module Value:sig
..end
val decode_ber : ?pos:int -> ?len:int -> string -> int * Value.value
pos
and len
may select a substring for the decoder. By default,
pos=0
, and len
as large as necessary to reach to the end of the
string.
The function returns the number of interpreted bytes, and the value.
It is not considered as an error if less than len
bytes are consumed.
The returned value represents implicitly tagged values as
Tagptr(class,tag,pc,pos,len)
. pos
and len
denote the substring
containting the contents. Use Netasn1.decode_ber_contents
to
further decode the value. You can use Tag
to put the
decoded value back into the tree.
val decode_ber_contents : ?pos:int ->
?len:int ->
?indefinite:bool ->
string ->
Value.pc -> Type_name.type_name -> int * Value.value
type_name
.
pos
and len
may select a substring for the decoder. By default,
pos=0
, and len
as large as necessary to reach to the end of the
string.
If indefinite
, the extent of the contents region is considered as
indefinite, and the special end marker is required. This is only
allowed when pc = Constructed
.
The function returns the number of interpreted bytes, and the value.
It is not considered as an error if less than len
bytes are consumed.
You need to use this function to recursively decode tagged values.
If you get a Tagptr(class,tag,pc,s,pos,len)
value, it depends on the
kind of the tag how to proceed:
Netasn1.decode_ber
again with
the given pos
and len
parameters.Netasn1.decode_ber_contents
with the right type name.val decode_ber_length : ?pos:int -> ?len:int -> string -> int
decode_ber
, but returns only the length.
This function skips many consistency checks.
val decode_ber_header : ?pos:int ->
?len:int ->
?skip_length_check:bool ->
string -> int * Value.tag_class * Value.pc * int * int option
let (hdr_len, tc, pc, tag, len_opt) = decode_ber_header s
:
Decodes only the header:hdr_len
will be the length of the header in bytestc
is the tag classpc
whether primitive or constructedtag
is the numeric tag valuelen_opt
is the length field, or None
if the header selects
indefinite lengthskip_length_check
is set, the function does not check whether
the string is long enough to hold the whole data part.