tlslite.utils.asn1parser module

Abstract Syntax Notation One (ASN.1) parsing

class tlslite.utils.asn1parser.ASN1Parser(bytes)[source]

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)[source]

Create an object from bytes.

Parameters:

bytes (bytearray) – DER encoded ASN.1 object

getChild(which)[source]

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)[source]

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()[source]

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)[source]

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)[source]