scapy.asn1.asn1

ASN.1 (Abstract Syntax Notation One)

class scapy.asn1.asn1.ASN1Codec(key: str, value: int)[source]

Bases: EnumElement

dec(s: bytes, context: Type[ASN1_Class] | None = None) ASN1_Object[Any][source]
get_stem() type[source]
register_stem(stem: Type[BERcodec_Object[Any]]) None[source]
safedec(s: bytes, context: Type[ASN1_Class] | None = None) ASN1_Object[Any][source]
class scapy.asn1.asn1.ASN1Tag(key: str, value: int, context: Optional[Type[ASN1_Class]] = None, codec: Optional[Dict[ASN1Codec, Type[BERcodec_Object[Any]]]]  # noqa: E501 = None)[source]

Bases: EnumElement

asn1_object(val: Any) ASN1_Object[Any][source]
clone() ASN1Tag[source]
get_codec(codec: Any) Type[BERcodec_Object[Any]][source]
register(codecnum: ASN1Codec, codec: Type[BERcodec_Object[Any]]) None[source]
register_asn1_object(asn1obj: Type[ASN1_Object[Any]]) None[source]
class scapy.asn1.asn1.ASN1_BADTAG(val: _K)[source]

Bases: ASN1_force

class scapy.asn1.asn1.ASN1_BIT_STRING(val: AnyStr, readable: bool = False)[source]

Bases: ASN1_Object[str]

ASN1_BIT_STRING values are bit strings like “011101”. A zero-bit padded readable string is provided nonetheless, which is stored in val_readable

tag = <ASN1Tag BIT_STRING[3]>
class scapy.asn1.asn1.ASN1_BMP_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag BMP_STRING[30]>
class scapy.asn1.asn1.ASN1_BOOLEAN(val: _K)[source]

Bases: ASN1_INTEGER

tag = <ASN1Tag BOOLEAN[1]>
exception scapy.asn1.asn1.ASN1_BadTag_Decoding_Error[source]

Bases: ASN1_Decoding_Error

class scapy.asn1.asn1.ASN1_COUNTER32(val: _K)[source]

Bases: ASN1_INTEGER

tag = <ASN1Tag COUNTER32[65]>
class scapy.asn1.asn1.ASN1_Class[source]

Bases: object

class scapy.asn1.asn1.ASN1_Class_UNIVERSAL[source]

Bases: ASN1_Class

ANY = <ASN1Tag ANY[0]>
BIT_STRING = <ASN1Tag BIT_STRING[3]>
BMP_STRING = <ASN1Tag BMP_STRING[30]>
BOOLEAN = <ASN1Tag BOOLEAN[1]>
CHAR_STRING = <ASN1Tag CHAR_STRING[29]>
COUNTER32 = <ASN1Tag COUNTER32[65]>
EMBEDDED_PDF = <ASN1Tag EMBEDDED_PDF[11]>
ENUMERATED = <ASN1Tag ENUMERATED[10]>
ERROR = <ASN1Tag ERROR[-3]>
EXTERNAL = <ASN1Tag EXTERNAL[8]>
GAUGE32 = <ASN1Tag GAUGE32[66]>
GENERALIZED_TIME = <ASN1Tag GENERALIZED_TIME[24]>
GENERAL_STRING = <ASN1Tag GENERAL_STRING[27]>
GRAPHIC_STRING = <ASN1Tag GRAPHIC_STRING[25]>
IA5_STRING = <ASN1Tag IA5_STRING[22]>
INTEGER = <ASN1Tag INTEGER[2]>
IPADDRESS = <ASN1Tag IPADDRESS[64]>
ISO646_STRING = <ASN1Tag ISO646_STRING[26]>
NONE = <ASN1Tag NONE[-1]>
NULL = <ASN1Tag NULL[5]>
NUMERIC_STRING = <ASN1Tag NUMERIC_STRING[18]>
OBJECT_DESCRIPTOR = <ASN1Tag OBJECT_DESCRIPTOR[7]>
OID = <ASN1Tag OID[6]>
PRINTABLE_STRING = <ASN1Tag PRINTABLE_STRING[19]>
RAW = <ASN1Tag RAW[-2]>
REAL = <ASN1Tag REAL[9]>
RELATIVE_OID = <ASN1Tag RELATIVE_OID[13]>
SEQUENCE = <ASN1Tag SEQUENCE[48]>
SET = <ASN1Tag SET[49]>
STRING = <ASN1Tag STRING[4]>
T61_STRING = <ASN1Tag T61_STRING[20]>
TIME_TICKS = <ASN1Tag TIME_TICKS[67]>
UNIVERSAL_STRING = <ASN1Tag UNIVERSAL_STRING[28]>
UTC_TIME = <ASN1Tag UTC_TIME[23]>
UTF8_STRING = <ASN1Tag UTF8_STRING[12]>
VIDEOTEX_STRING = <ASN1Tag VIDEOTEX_STRING[21]>
name = 'UNIVERSAL'
class scapy.asn1.asn1.ASN1_Class_metaclass(name: str, bases: Tuple[type, ...], dct: Dict[str, Any])[source]

Bases: Enum_metaclass

element_class[source]

alias of ASN1Tag

class scapy.asn1.asn1.ASN1_Codecs[source]

Bases: object

BACnet = <ASN1Codec BACnet[6]>
BER = <ASN1Codec BER[1]>
CER = <ASN1Codec CER[4]>
DER = <ASN1Codec DER[2]>
LWER = <ASN1Codec LWER[5]>
OER = <ASN1Codec OER[7]>
PER = <ASN1Codec PER[3]>
SER = <ASN1Codec SER[8]>
XER = <ASN1Codec XER[9]>
class scapy.asn1.asn1.ASN1_Codecs_metaclass(name: Any, bases: str, dct: Any)[source]

Bases: Enum_metaclass

element_class[source]

alias of ASN1Codec

class scapy.asn1.asn1.ASN1_DECODING_ERROR(val: bytes | ASN1_Object[Any], exc: Exception | None = None)[source]

Bases: _ASN1_ERROR

enc(codec: Any) bytes[source]
tag = <ASN1Tag ERROR[-3]>
exception scapy.asn1.asn1.ASN1_Decoding_Error[source]

Bases: ASN1_Error

class scapy.asn1.asn1.ASN1_ENUMERATED(val: _K)[source]

Bases: ASN1_INTEGER

tag = <ASN1Tag ENUMERATED[10]>
exception scapy.asn1.asn1.ASN1_Encoding_Error[source]

Bases: ASN1_Error

exception scapy.asn1.asn1.ASN1_Error[source]

Bases: Scapy_Exception

class scapy.asn1.asn1.ASN1_GAUGE32(val: _K)[source]

Bases: ASN1_INTEGER

tag = <ASN1Tag GAUGE32[66]>
class scapy.asn1.asn1.ASN1_GENERALIZED_TIME(val: str | datetime)[source]

Bases: ASN1_STRING

Improved version of ASN1_GENERALIZED_TIME, properly handling time zones and all string representation formats defined by ASN.1. These are:

  1. Local time only: YYYYMMDDHH[MM[SS[.fff]]]

  2. Universal time (UTC time) only: YYYYMMDDHH[MM[SS[.fff]]]Z

  3. Difference between local and UTC times: YYYYMMDDHH[MM[SS[.fff]]]+-HHMM

It also handles ASN1_UTC_TIME, which allows:

  1. Universal time (UTC time) only: YYMMDDHHMM[SS[.fff]]Z

  2. Difference between local and UTC times: YYMMDDHHMM[SS[.fff]]+-HHMM

Note the differences: Year is only two digits, minutes are not optional and there is no milliseconds.

pretty_time = None
tag = <ASN1Tag GENERALIZED_TIME[24]>
class scapy.asn1.asn1.ASN1_GENERAL_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag GENERAL_STRING[27]>
class scapy.asn1.asn1.ASN1_IA5_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag IA5_STRING[22]>
class scapy.asn1.asn1.ASN1_INTEGER(val: _K)[source]

Bases: ASN1_Object[int]

tag = <ASN1Tag INTEGER[2]>
class scapy.asn1.asn1.ASN1_IPADDRESS(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag IPADDRESS[64]>
class scapy.asn1.asn1.ASN1_ISO646_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag ISO646_STRING[26]>
class scapy.asn1.asn1.ASN1_NULL(val: _K)[source]

Bases: ASN1_Object[None]

tag = <ASN1Tag NULL[5]>
class scapy.asn1.asn1.ASN1_NUMERIC_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag NUMERIC_STRING[18]>
class scapy.asn1.asn1.ASN1_OID(val: str)[source]

Bases: ASN1_Object[str]

tag = <ASN1Tag OID[6]>
class scapy.asn1.asn1.ASN1_Object(val: _K)[source]

Bases: Generic[_K]

command() str[source]
enc(codec: Any) bytes[source]
show(lvl: int = 0) None[source]
strshow(lvl: int = 0) str[source]
tag = <ASN1Tag ANY[0]>
class scapy.asn1.asn1.ASN1_Object_metaclass(name: str, bases: Tuple[type, ...], dct: Dict[str, Any])[source]

Bases: _Generic_metaclass

class scapy.asn1.asn1.ASN1_PRINTABLE_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag PRINTABLE_STRING[19]>
class scapy.asn1.asn1.ASN1_SEQUENCE(val: _K)[source]

Bases: ASN1_Object[List[Any]]

strshow(lvl: int = 0) str[source]
tag = <ASN1Tag SEQUENCE[48]>
class scapy.asn1.asn1.ASN1_SET(val: _K)[source]

Bases: ASN1_SEQUENCE

tag = <ASN1Tag SET[49]>
class scapy.asn1.asn1.ASN1_STRING(val: _K)[source]

Bases: ASN1_Object[str]

tag = <ASN1Tag STRING[4]>
class scapy.asn1.asn1.ASN1_T61_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag T61_STRING[20]>
class scapy.asn1.asn1.ASN1_TIME_TICKS(val: _K)[source]

Bases: ASN1_INTEGER

tag = <ASN1Tag TIME_TICKS[67]>
class scapy.asn1.asn1.ASN1_UNIVERSAL_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag UNIVERSAL_STRING[28]>
class scapy.asn1.asn1.ASN1_UTC_TIME(val: str | datetime)[source]

Bases: ASN1_GENERALIZED_TIME

tag = <ASN1Tag UTC_TIME[23]>
class scapy.asn1.asn1.ASN1_UTF8_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag UTF8_STRING[12]>
class scapy.asn1.asn1.ASN1_VIDEOTEX_STRING(val: _K)[source]

Bases: ASN1_STRING

tag = <ASN1Tag VIDEOTEX_STRING[21]>
class scapy.asn1.asn1.ASN1_force(val: _K)[source]

Bases: _ASN1_ERROR

enc(codec: Any) bytes[source]
tag = <ASN1Tag RAW[-2]>
class scapy.asn1.asn1.RandASN1Object(objlist: List[Type[ASN1_Object[Any]]] | None = None)[source]

Bases: RandField[ASN1_Object[Any]]