return a readbyte implementation which uses another readbyte, but allows setting a read boundry. Useful for constructing views of the octet stream which end at the end of a ber structure. This is essential for reading certian structures because length is only encoded in the toplevel in order to save space. Currently only implemented for definite lengths.
a readbyte implementation which reads from an FD. It implements a peek buffer, so it can garentee that it will work with rb_of_ber_element, even with blocking fds.
Explanation of optional arguments: The optional arguments are there to deal with a number of situations, cls, and tag are for context specific or application situations where it is expected that the value will not be marked with the class and tag defined in X.680. Contents is there for akward situations which arise because of the choice structure. Normally the decode functions will always read the header for you, however with the choice structure this is impossible. In this case you should read the header manually, determine which decode function to call, unpack the contents with read_contents, and send them in the contents optional. If contents is not None, then readbyte will never be called, and no attempt will be made to read the header or length.
val decode_ber_bool :
?peek:bool ->?cls:ber_class->?tag:int ->?contents:string option->readbyte->
bool
Encoding/Decoding of the boolean primative ASN.1 type. Encode function encodes a valid ber type, including the header and length octets.
val encode_ber_bool : ?cls:ber_class->?tag:int ->bool -> string
val decode_ber_int32 :
?peek:bool ->?cls:ber_class->?tag:int ->?contents:string option->readbyte->
int32
Encoding/Decoding of the integer primative ASN.1 type. Note, in this library, integers are represented as 32 bit values. In ASN.1 there is no practical limit to the size of an integer, later on, this library may provide an encoder/decoder to Int64, and Bigints, however for now, this will have to do. Encode function encodes a valid ber type, including the header and length octets
val encode_ber_int32 : ?cls:ber_class->?tag:int ->int32 -> string
val decode_ber_enum :
?peek:bool ->?cls:ber_class->?tag:int ->?contents:string option->readbyte->
int32
Encoding/Decoding of enum primative ASN.1 type. Enums are simply integers, the same drawbacks apply as for decode_ber_int32. Encode function encodes a valid ber type, including the header and length octets
val encode_ber_enum : ?cls:ber_class->?tag:int ->int32 -> string
val decode_ber_octetstring :
?peek:bool ->?cls:ber_class->?tag:int ->?contents:string option->readbyte->
string
Encoding/Decoding of octetstring ASN.1 types. The Nested or "segmented" version of the octetstring encoding described in X.690 is not yet supported. Encode function encodes a valid ber type, including the header and length octets
val encode_ber_octetstring : ?cls:ber_class->?tag:int ->string -> string
val decode_ber_null :
?peek:bool ->?cls:ber_class->?tag:int ->?contents:string option->readbyte->
unit
Encoding/Decoding of Null ASN.1 type. Almost useful as an assertion-type operation
val encode_ber_null : ?cls:ber_class->?tag:int ->unit -> string
val encode_berval_list : ?buf:Buffer.t->('a-> string)->'a list-> string
this function is for encoding lists of bervals, a common case. you pass it a list of things to encode, and an encoding function, and it will apply the encoding function to each element in the list, storing the resulting encoding in a buffer (which you may either pass in or not)
val decode_berval_list :
?lst:'a list->(readbyte->'a)->readbyte->'a list
this is the reverse of the above, it takes a readbyte structure, and returns a list of decoded elements, processed according to the decoder function you pass in. Note, that you MUST pass a readbyte structure built with readbyte_of_string, OR, your reabyte function must raise Stream.Failure when you reach the end of input. Otherwise this function will explode. That said, it is usually not practical to pass anything but a readbyte created by readbyte_of_string so this should not be a huge problem.