Home | Trees | Indices | Help |
---|
|
Parser for TLV and LV byte-based encodings.
Parser that can handle arbitrary byte-based encodings usually employed in Type-Length-Value or Length-Value binary encoding protocols like ASN.1 or TLS
Note: if the raw bytes don't match expected values (like trying to read a 4-byte integer from a 2-byte buffer), most methods will raise a SyntaxError exception.
TODO: don't use an exception used by language parser to indicate errors in application code.
|
|||
|
|||
|
|||
int |
|
||
bytearray |
|
||
list of int |
|
||
|
|||
bytearray |
|
||
list of int |
|
||
list of tuple of int |
|
||
|
|||
|
|||
|
|
Bind raw bytes with parser.
|
Check if there is data in structure left for parsing. Returns True if the whole structure was parsed, False if there is some data left. Will raise an exception if overflow occured (amount of data read was greater than expected size) |
Read a single big-endian integer value encoded in 'length' bytes.
|
Read a string of bytes encoded in 'lengthBytes' bytes.
|
Read a list of static length with same-sized ints.
|
Read a variable length string with a fixed length.
|
Read a variable length list of same-sized integers.
|
Read a variable length list of same sized tuples.
|
Set length of struct and start a length check for parsing.
|
Read length of struct and start a length check for parsing.
|
Stop struct parsing, verify that no under- or overflow occurred. In case the expected length was mismatched with actual length of processed data, raises an exception. |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 | http://epydoc.sourceforge.net |