tlslite.utils.asn1parser module

Abstract Syntax Notation One (ASN.1) parsing

class tlslite.utils.asn1parser.ASN1Parser(bytes)

Bases: object

Parser and storage of ASN.1 DER encoded objects.

Variables:
  • length (int) – length of the value of the tag
  • value (bytearray) – literal value of the tag
__init__(bytes)

Create an object from bytes.

Parameters:bytes (bytearray) – DER encoded ASN.1 object
getChild(which)

Return n-th child assuming that the object is a SEQUENCE.

Parameters:which (int) – ordinal of the child to return
Return type:ASN1Parser
Returns:decoded child object
getChildBytes(which)

Return raw encoding of n-th child, assume self is a SEQUENCE

Parameters:which (int) – ordinal of the child to return
Return type:bytearray
Returns:raw child object
getChildCount()

Return number of children, assuming that the object is a SEQUENCE.

Return type:int
Returns:number of children in the object
class tlslite.utils.asn1parser.ASN1Type(tag_class, is_primitive, tag_id)

Bases: object

Class that represents the ASN.1 type bit octet. Consists of a class (universal(0), application(1), context-specific(2) or private(3)), boolean value that indicates if a type is constructed or primitive and the ASN1 type itself.

Variables:
  • field – bit octet
  • tagClass (int) – type’s class
  • isPrimitive (int) – equals to 0 if the type is primitive, 1 if not
  • tagId (int) – ANS1 tag number
__init__(tag_class, is_primitive, tag_id)

Initialize self. See help(type(self)) for accurate signature.