SSL - Secure Sockets Layer

pcapkit.protocols.application.ssl.protocol contains SSL, which is the umbrella base class for the Secure Sockets Layer protocol family [*] – the SSL versions, Transport Layer Security and Datagram TLS:

  • SSLv2 – SSL 2.0, whose record layer shares no wire format with the others;

  • TLS – SSLv3 and TLS 1.0 through TLS 1.3, with SSLv3 as its thin subclass for explicit construction;

  • DTLS – DTLS 1.0, 1.2 and 1.3.

SSL.id lists the direct concrete subclasses, so a lookup keyed on SSL matches any of them.

The TLS record header (RFC 9846 Section 5.1) is a ContentType, a legacy record version and a length. The DTLS DTLSPlaintext header (RFC 9147 Section 4) has the same fields plus an epoch and a 48-bit sequence number between the version and the length, and DTLS adds a fragment header to each handshake message. Each record header is declared in its subclass’s own schema, and DTLS reads the epoch and sequence number. This base class carries the logic TLS and DTLS share – content-type dispatch, handshake-message decoding (including the DTLS fragment header), the extension registry and the header schema of each extension’s extension_data (pcapkit.protocols.application.ssl.schema), and the record-level validation that keeps dispatch from accepting bytes that cannot be a genuine record.

Added in version 1.6.0.

Removed in version 1.7.0: pcapkit.protocols.application.ssl.protocol.TLS13_VERSION and pcapkit.protocols.application.ssl.protocol.DTLS13_VERSION, now pcapkit.protocols.application.ssl.const.TLS13_VERSION and pcapkit.protocols.application.ssl.const.DTLS13_VERSION (#2896).


class pcapkit.protocols.application.ssl.protocol.SSL[_PT: Data, _ST: Schema](file, length=None, /, *, layer=None, protocol=None, context=None)[source]

Bases: Application[_PT, _ST], Generic[_PT, _ST]

Umbrella base class for the SSL protocol family: the SSL versions, TLS and DTLS.

These extensions decode, each only in the handshake messages its RFC defines it in, and connection_id only in a DTLS record (RFC 9146 Section 10.2):

Extension Type

Extension Parser

Extension Constructor

server_name

_read_ext_server_name()

_make_ext_server_name()

status_request

_read_ext_status_request()

_make_ext_status_request()

supported_groups

_read_ext_supported_groups()

_make_ext_supported_groups()

ec_point_formats

_read_ext_ec_point_formats()

_make_ext_ec_point_formats()

signature_algorithms

_read_ext_signature_algorithms()

_make_ext_signature_algorithms()

application_layer_protocol_negotiation

_read_ext_alpn()

_make_ext_alpn()

signed_certificate_timestamp

_read_ext_signed_certificate_timestamp()

_make_ext_signed_certificate_timestamp()

padding

_read_ext_padding()

_make_ext_padding()

extended_main_secret

_read_ext_extended_main_secret()

_make_ext_extended_main_secret()

compress_certificate

_read_ext_compress_certificate()

_make_ext_compress_certificate()

record_size_limit

_read_ext_record_size_limit()

_make_ext_record_size_limit()

session_ticket

_read_ext_session_ticket()

_make_ext_session_ticket()

pre_shared_key

_read_ext_pre_shared_key()

_make_ext_pre_shared_key()

early_data

_read_ext_early_data()

_make_ext_early_data()

supported_versions

_read_ext_supported_versions()

_make_ext_supported_versions()

cookie

_read_ext_cookie()

_make_ext_cookie()

psk_key_exchange_modes

_read_ext_psk_key_exchange_modes()

_make_ext_psk_key_exchange_modes()

post_handshake_auth

_read_ext_post_handshake_auth()

_make_ext_post_handshake_auth()

key_share

_read_ext_key_share()

_make_ext_key_share()

connection_id

_read_ext_connection_id()

_make_ext_connection_id()

encrypted_client_hello

_read_ext_ech()

_make_ext_ech()

renegotiation_info

_read_ext_renegotiation_info()

_make_ext_renegotiation_info()

GREASE values (RFC 8701) are Reserved extension types with no decoder, so their bodies stay raw octets.

Each type’s layout is the schema Extension registers for it: a parser is handed the extension_data unpacked by that schema, and a constructor returns one.

Changed in version 1.7.0: Each extension decodes and builds through a schema of its own, in pcapkit.protocols.application.ssl.schema (#2833).

Defaults

__extension__: DefaultDict[ExtensionType | int, str | tuple[Callable[[ExtensionType, Extension, HandshakeType], ExtensionData | bytes], Callable[[ExtensionType, ExtensionData | None, HandshakeType, Any], Extension]]]

Extension type to method mapping, see _read_tls_extensions() and _make_tls_extensions(). A str value names the methods _read_ext_${name} and _make_ext_${name}, falling back to _read_ext_unknown() and _make_ext_unknown() when the class has no such method, as an unregistered type does; any other value is a (parser, constructor) pair of callables. Each type’s extension_data layout is in the Extension registry, so a parser is handed the extension_data unpacked by that schema and a constructor returns one.

Changed in version 1.7.0: A parser takes, and a constructor returns, the extension_data schema rather than its octets (#2833).

_dtls: bool = False

Whether the records are DTLS’s, which alone carry a DTLS-only extension (RFC 9146 Section 10.2); DTLS sets it.

Methods

classmethod id()[source]

Index ID of the protocol.

Returns:

the direct concrete members of the family. SSLv3 is not listed, as it is a subclass of TLS.

Return type:

tuple[Literal['SSLv2'], Literal['TLS'], Literal['DTLS']]

classmethod register_extension(code, meth)[source]

Register an extension parser.

Parameters:
Warns:

RegistryWarning – If a different entry is already registered for code; it is overwritten. Handing back the entry already stored, or one equal to it, is a silent no-op. The entry code shipped with is accepted like any other, so an override can be undone (#1362, #1363).

Changed in version 1.7.0: The parser takes, and the constructor returns, the extension_data schema rather than its octets (#2833).

Utilities

_read_ext_unknown(ext_type, schema, *, msg_type)[source]

Read an extension with no decoder registered: its raw octets.

Parameters:
Return type:

bytes

Returns:

The extension_data octets unchanged.

_read_ext_server_name(ext_type, schema, *, msg_type)[source]

Read a server_name extension.

Structure of ServerNameList [RFC 6066 Section 3]:

struct {
    NameType name_type;
    select (name_type) {
        case host_name: HostName;
    } name;
} ServerName;

enum {
    host_name(0), (255)
} NameType;

opaque HostName<1..2^16-1>;

struct {
    ServerName server_name_list<1..2^16-1>
} ServerNameList;

A ServerHello or EncryptedExtensions carries the extension empty.

Parameters:
Return type:

ServerNameList | Empty | bytes

Returns:

The decoded list for a ClientHello, an empty structure for a ServerHello or EncryptedExtensions, or the octets for a message the structure does not cover.

Raises:

ProtocolError – If a name is of a type other than host_name, whose name has no defined structure.

_read_ext_status_request(ext_type, schema, *, msg_type)[source]

Read a status_request extension.

Structure of CertificateStatusRequest [RFC 6066 Section 8]:

struct {
    CertificateStatusType status_type;
    select (status_type) {
        case ocsp: OCSPStatusRequest;
    } request;
} CertificateStatusRequest;

enum { ocsp(1), (255) } CertificateStatusType;

struct {
    ResponderID responder_id_list<0..2^16-1>;
    Extensions  request_extensions;
} OCSPStatusRequest;

opaque ResponderID<1..2^16-1>;
opaque Extensions<0..2^16-1>;

A ServerHello carries the extension empty.

Parameters:
Return type:

CertificateStatusRequest | Empty | bytes

Returns:

The decoded request for a ClientHello, an empty structure for a ServerHello, or the octets for a message the structure does not cover.

Raises:

ProtocolError – If the status type is other than ocsp, whose request has no defined structure.

_read_ext_supported_groups(ext_type, schema, *, msg_type)[source]

Read a supported_groups extension.

Structure of NamedGroupList [RFC 9846 Section 4.3.7]:

struct {
    NamedGroup named_group_list<2..2^16-1>;
} NamedGroupList;
Parameters:
Return type:

NamedGroupList | bytes

Returns:

The decoded list in a ClientHello or EncryptedExtensions, where the extension is defined; or the octets in any other message.

_read_ext_ec_point_formats(ext_type, schema, *, msg_type)[source]

Read an ec_point_formats extension.

Structure of ECPointFormatList [RFC 8422 Section 5.1.2]:

enum {
    uncompressed (0),
    deprecated (1..2),
    reserved (248..255)
} ECPointFormat;
struct {
    ECPointFormat ec_point_format_list<1..2^8-1>
} ECPointFormatList;
Parameters:
Return type:

ECPointFormatList | bytes

Returns:

The decoded list in a ClientHello or ServerHello, where the extension is defined; or the octets in any other message.

_read_ext_signature_algorithms(ext_type, schema, *, msg_type)[source]

Read a signature_algorithms extension.

Structure of SignatureSchemeList [RFC 9846 Section 4.3.3]:

struct {
    SignatureScheme supported_signature_algorithms<2..2^16-2>;
} SignatureSchemeList;
Parameters:
Return type:

SignatureSchemeList | bytes

Returns:

The decoded list in a ClientHello or CertificateRequest, where the extension is defined; or the octets in any other message.

_read_ext_alpn(ext_type, schema, *, msg_type)[source]

Read an application_layer_protocol_negotiation extension.

Structure of ProtocolNameList [RFC 7301 Section 3.1]:

opaque ProtocolName<1..2^8-1>;

struct {
    ProtocolName protocol_name_list<2..2^16-1>
} ProtocolNameList;

A server sends it in a ServerHello, or in TLS 1.3 an EncryptedExtensions (RFC 9846 Section 4.3), naming one protocol.

Parameters:
Return type:

ProtocolNameList | bytes

Returns:

The decoded list in a ClientHello, ServerHello or EncryptedExtensions, where the extension is defined; or the octets in any other message.

_read_ext_signed_certificate_timestamp(ext_type, schema, *, msg_type)[source]

Read a signed_certificate_timestamp extension.

Structure of SignedCertificateTimestampList [RFC 6962 Section 3.3]:

opaque SerializedSCT<1..2^16-1>;

struct {
    SerializedSCT sct_list <1..2^16-1>;
} SignedCertificateTimestampList;

A ClientHello carries the extension empty, and a ServerHello the list (RFC 6962 Section 3.3.1).

Parameters:
Return type:

SignedCertificateTimestampList | Empty | bytes

Returns:

An empty structure for a ClientHello, the decoded list for a ServerHello, or the octets for a message the structure does not cover.

_read_ext_padding(ext_type, schema, *, msg_type)[source]

Read a padding extension.

Its extension_data is any number of zero octets [RFC 7685 Section 3], kept as captured.

Parameters:
Return type:

Padding | bytes

Returns:

The padding in a ClientHello, where the extension is defined; or the octets in any other message.

_read_ext_extended_main_secret(ext_type, schema, *, msg_type)[source]

Read an extended_main_secret extension, whose extension_data is empty [RFC 7627 Section 5.1].

Parameters:
Return type:

Empty | bytes

Returns:

An empty structure in a ClientHello or ServerHello, where the extension is defined; or the octets in any other message.

_read_ext_compress_certificate(ext_type, schema, *, msg_type)[source]

Read a compress_certificate extension.

Structure of CertificateCompressionAlgorithms [RFC 8879 Section 3]:

enum {
    zlib(1),
    brotli(2),
    zstd(3),
    (65535)
} CertificateCompressionAlgorithm;

struct {
    CertificateCompressionAlgorithm algorithms<2..2^8-2>;
} CertificateCompressionAlgorithms;
Parameters:
Return type:

CertificateCompressionAlgorithms | bytes

Returns:

The decoded list in a ClientHello, where the extension is defined; or the octets in any other message.

_read_ext_record_size_limit(ext_type, schema, *, msg_type)[source]

Read a record_size_limit extension.

Structure of RecordSizeLimit [RFC 8449 Section 4]:

uint16 RecordSizeLimit;

The extension is valid in every TLS version (RFC 8449 Section 1), so a server answers in its ServerHello before TLS 1.3 and in EncryptedExtensions from it.

Parameters:
Return type:

RecordSizeLimit | bytes

Returns:

The decoded limit in a ClientHello, ServerHello or EncryptedExtensions, where the extension is defined; or the octets in any other message.

_read_ext_session_ticket(ext_type, schema, *, msg_type)[source]

Read a session_ticket extension, whose extension_data is the ticket itself, with no length of its own [RFC 5077 Section 3.2].

Parameters:
Return type:

SessionTicket | bytes

Returns:

The ticket in a ClientHello or ServerHello, where the extension is defined; or the octets in any other message.

_read_ext_pre_shared_key(ext_type, schema, *, msg_type)[source]

Read a pre_shared_key extension.

Structure of PreSharedKeyExtension [RFC 9846 Section 4.3.11]:

struct {
    opaque identity<1..2^16-1>;
    uint32 obfuscated_ticket_age;
} PskIdentity;

opaque PskBinderEntry<32..255>;

struct {
    PskIdentity identities<7..2^16-1>;
    PskBinderEntry binders<33..2^16-1>;
} OfferedPsks;

struct {
    select (Handshake.msg_type) {
        case client_hello: OfferedPsks;
        case server_hello: uint16 selected_identity;
    };
} PreSharedKeyExtension;
Parameters:
Return type:

OfferedPsks | PreSharedKeyServerHello | bytes

Returns:

The decoded structure for msg_type; or the octets for a message the structure does not cover.

_read_ext_early_data(ext_type, schema, *, msg_type)[source]

Read an early_data extension.

Structure of EarlyDataIndication [RFC 9846 Section 4.3.10]:

struct {} Empty;

struct {
    select (Handshake.msg_type) {
        case new_session_ticket:   uint32 max_early_data_size;
        case client_hello:         Empty;
        case encrypted_extensions: Empty;
    };
} EarlyDataIndication;
Parameters:
Return type:

Empty | bytes

Returns:

An empty structure for a ClientHello or EncryptedExtensions, or the octets for a message the structure does not cover.

_read_ext_supported_versions(ext_type, schema, *, msg_type)[source]

Read a supported_versions extension.

Structure of SupportedVersions [RFC 9846 Section 4.3.1]:

struct {
    select (Handshake.msg_type) {
        case client_hello:
             ProtocolVersion versions<2..254>;

        case server_hello: /* and HelloRetryRequest */
             ProtocolVersion selected_version;
    };
} SupportedVersions;
Parameters:
Return type:

SupportedVersionsClientHello | SupportedVersionsServerHello | bytes

Returns:

The decoded versions for msg_type; or the octets for a message the structure does not cover.

Read a cookie extension.

Structure of Cookie [RFC 9846 Section 4.3.2]:

struct {
    opaque cookie<1..2^16-1>;
} Cookie;
Parameters:
Return type:

Cookie | bytes

Returns:

The decoded cookie in a ClientHello or HelloRetryRequest, where the extension is defined; or the octets in any other message.

_read_ext_psk_key_exchange_modes(ext_type, schema, *, msg_type)[source]

Read a psk_key_exchange_modes extension.

Structure of PskKeyExchangeModes [RFC 9846 Section 4.3.9]:

enum { psk_ke(0), psk_dhe_ke(1), (255) } PskKeyExchangeMode;

struct {
    PskKeyExchangeMode ke_modes<1..255>;
} PskKeyExchangeModes;
Parameters:
Return type:

PskKeyExchangeModes | bytes

Returns:

The decoded modes in a ClientHello, where the extension is defined; or the octets in any other message.

_read_ext_post_handshake_auth(ext_type, schema, *, msg_type)[source]

Read a post_handshake_auth extension, whose extension_data is empty [RFC 9846 Section 4.3.6].

Parameters:
Return type:

Empty | bytes

Returns:

An empty structure in a ClientHello, where the extension is defined; or the octets in any other message.

_read_ext_key_share(ext_type, schema, *, msg_type)[source]

Read a key_share extension.

Structure of key_share [RFC 9846 Section 4.3.8]:

struct {
    NamedGroup group;
    opaque key_exchange<1..2^16-1>;
} KeyShareEntry;

struct {
    KeyShareEntry client_shares<0..2^16-1>;
} KeyShareClientHello;

struct {
    NamedGroup selected_group;
} KeyShareHelloRetryRequest;

struct {
    KeyShareEntry server_share;
} KeyShareServerHello;
Parameters:
Return type:

KeyShareClientHello | KeyShareHelloRetryRequest | KeyShareServerHello | bytes

Returns:

The decoded structure for msg_type; or the octets for a message the structure does not cover.

_read_ext_connection_id(ext_type, schema, *, msg_type)[source]

Read a connection_id extension.

Structure of ConnectionId [RFC 9146 Section 3]:

struct {
    opaque cid<0..2^8-1>;
} ConnectionId;

The extension is DTLS-only, in a ClientHello or ServerHello (RFC 9146 Section 3, RFC 9146 Section 10.2), and DTLS 1.3 keeps it in those two messages (RFC 9147 Section 9.1).

Parameters:
Return type:

ConnectionId | bytes

Returns:

The decoded connection ID in a DTLS ClientHello or ServerHello, where the extension is defined; or the octets in any other message, and in a TLS record.

_read_ext_ech(ext_type, schema, *, msg_type)[source]

Read an encrypted_client_hello extension.

Structure of encrypted_client_hello [RFC 9849 Section 5]:

enum { outer(0), inner(1) } ECHClientHelloType;

struct {
   ECHClientHelloType type;
   select (ECHClientHello.type) {
       case outer:
           HpkeSymmetricCipherSuite cipher_suite;
           uint8 config_id;
           opaque enc<0..2^16-1>;
           opaque payload<1..2^16-1>;
       case inner:
           Empty;
   };
} ECHClientHello;

struct {
   ECHConfigList retry_configs;
} ECHEncryptedExtensions;

struct {
   opaque confirmation[8];
} ECHHelloRetryRequest;

ECHConfigList is ECHConfig ECHConfigList<4..2^16-1>, each ECHConfig read by _read_ech_config().

Parameters:
Returns:

an ECHClientHello of either type, an ECHHelloRetryRequest or an ECHEncryptedExtensions; or the octets for a message the structure does not cover.

Return type:

ECHClientHelloOuter | ECHClientHelloInner | ECHHelloRetryRequest | ECHEncryptedExtensions | bytes

Raises:

ProtocolError – If a ClientHello’s names a type other than outer and inner.

_read_ext_renegotiation_info(ext_type, schema, *, msg_type)[source]

Read a renegotiation_info extension.

Structure of RenegotiationInfo [RFC 5746 Section 3.2]:

struct {
    opaque renegotiated_connection<0..255>;
} RenegotiationInfo;
Parameters:
Return type:

RenegotiationInfo | bytes

Returns:

The decoded structure in a ClientHello or ServerHello, where the extension is defined; or the octets in any other message.

_make_ext_unknown(ext_type, data=None, *, msg_type, **kwargs)[source]

Make an extension with no constructor registered.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (ExtensionData | None) – Decoded extension_data, which this type has no structure to write.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

UnknownExtension

Returns:

Empty extension_data when data is None.

Raises:

ProtocolError – If data is given.

_make_ext_server_name(ext_type, data=None, *, msg_type, server_name_list=(), **kwargs)[source]

Make a server_name extension.

data decides the structure when given, msg_type otherwise.

Parameters:
Return type:

ServerNameExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If neither data nor msg_type names a structure.

_make_ext_status_request(ext_type, data=None, *, msg_type, status_type=CertificateStatusType.ocsp, responder_id_list=(), request_extensions=b'', **kwargs)[source]

Make a status_request extension.

data decides the structure when given, msg_type otherwise.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (CertificateStatusRequest | Empty | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • status_type (CertificateStatusType | int) – Status type for a ClientHello, if data is not given.

  • responder_id_list (Iterable[bytes]) – ResponderID values for a ClientHello, if data is not given.

  • request_extensions (bytes) – OCSP request Extensions for a ClientHello, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

StatusRequestExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If neither data nor msg_type names a structure, or the status type is not ocsp.

_make_ext_supported_groups(ext_type, data=None, *, msg_type, named_group_list=(), **kwargs)[source]

Make a supported_groups extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (NamedGroupList | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • named_group_list (Iterable[int]) – NamedGroup values, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

SupportedGroupsExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello or EncryptedExtensions.

_make_ext_ec_point_formats(ext_type, data=None, *, msg_type, ec_point_format_list=(), **kwargs)[source]

Make an ec_point_formats extension.

Parameters:
Return type:

ECPointFormatsExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello or ServerHello, or if a point format is not an int that fits in one octet.

_make_ext_signature_algorithms(ext_type, data=None, *, msg_type, supported_signature_algorithms=(), **kwargs)[source]

Make a signature_algorithms extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (SignatureSchemeList | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • supported_signature_algorithms (Iterable[int]) – SignatureScheme values, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

SignatureAlgorithmsExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello or CertificateRequest.

_make_ext_alpn(ext_type, data=None, *, msg_type, protocol_name_list=(), **kwargs)[source]

Make an application_layer_protocol_negotiation extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (ProtocolNameList | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • protocol_name_list (Iterable[bytes]) – ProtocolName octet strings, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

ALPNExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello, ServerHello or EncryptedExtensions.

_make_ext_signed_certificate_timestamp(ext_type, data=None, *, msg_type, sct_list=(), **kwargs)[source]

Make a signed_certificate_timestamp extension.

data decides the structure when given, msg_type otherwise.

Parameters:
Return type:

SignedCertificateTimestampExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If neither data nor msg_type names a structure.

_make_ext_padding(ext_type, data=None, *, msg_type, padding=b'', **kwargs)[source]

Make a padding extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (Padding | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • padding (bytes) – Padding octets, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

PaddingExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello.

_make_ext_extended_main_secret(ext_type, data=None, *, msg_type, **kwargs)[source]

Make an extended_main_secret extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (Empty | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

ExtendedMainSecretExtension

Returns:

Constructed extension_data schema, which is empty.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello or ServerHello, or if data is a structure other than an empty one.

_make_ext_compress_certificate(ext_type, data=None, *, msg_type, algorithms=(), **kwargs)[source]

Make a compress_certificate extension.

Parameters:
Return type:

CompressCertificateExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello, or if an algorithm is not an int that fits in two octets.

_make_ext_record_size_limit(ext_type, data=None, *, msg_type, record_size_limit=None, **kwargs)[source]

Make a record_size_limit extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (RecordSizeLimit | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • record_size_limit (int | None) – Largest record, in octets, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

RecordSizeLimitExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello, ServerHello or EncryptedExtensions, or if neither data nor record_size_limit is given.

_make_ext_session_ticket(ext_type, data=None, *, msg_type, ticket=b'', **kwargs)[source]

Make a session_ticket extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (SessionTicket | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • ticket (bytes) – The ticket, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

SessionTicketExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello or ServerHello.

_make_ext_pre_shared_key(ext_type, data=None, *, msg_type, identities=(), binders=(), selected_identity=None, **kwargs)[source]

Make a pre_shared_key extension.

data decides the structure when given, msg_type otherwise.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (OfferedPsks | PreSharedKeyServerHello | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • identities (Iterable[PskIdentity]) – Identities for a ClientHello, if data is not given.

  • binders (Iterable[bytes]) – PskBinderEntry values for a ClientHello, if data is not given.

  • selected_identity (int | None) – Index of the identity a ServerHello selects, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

PreSharedKeyExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If neither data nor msg_type names a structure, or selected_identity is missing.

_make_ext_early_data(ext_type, data=None, *, msg_type, **kwargs)[source]

Make an early_data extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (Empty | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

EarlyDataExtension

Returns:

Constructed extension_data schema, which is empty.

Raises:

ProtocolError – If data is a structure other than an empty one, or is not given for a message whose structure is not empty.

_make_ext_supported_versions(ext_type, data=None, *, msg_type, versions=(), selected_version=None, **kwargs)[source]

Make a supported_versions extension.

data decides the structure when given, msg_type otherwise.

Parameters:
Return type:

SupportedVersionsExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If neither data nor msg_type names a structure, or selected_version is missing.

Make a cookie extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (Cookie | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • cookie (bytes) – The cookie, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

CookieExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello or HelloRetryRequest.

_make_ext_psk_key_exchange_modes(ext_type, data=None, *, msg_type, ke_modes=(), **kwargs)[source]

Make a psk_key_exchange_modes extension.

Parameters:
Return type:

PskKeyExchangeModesExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello, or if a mode is not an int that fits in one octet.

_make_ext_post_handshake_auth(ext_type, data=None, *, msg_type, **kwargs)[source]

Make a post_handshake_auth extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (Empty | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

PostHandshakeAuthExtension

Returns:

Constructed extension_data schema, which is empty.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello, or if data is a structure other than an empty one.

_make_ext_key_share(ext_type, data=None, *, msg_type, client_shares=(), selected_group=None, server_share=None, **kwargs)[source]

Make a key_share extension.

data decides the structure when given, msg_type otherwise.

Parameters:
Return type:

KeyShareExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If neither data nor msg_type names a structure, or the argument it needs is missing.

_make_ext_connection_id(ext_type, data=None, *, msg_type, cid=b'', **kwargs)[source]

Make a connection_id extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (ConnectionId | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • cid (bytes) – Connection ID, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

ConnectionIdExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a TLS record, or for a message other than a ClientHello or ServerHello.

_make_ext_ech(ext_type, data=None, *, msg_type, inner=False, cipher_suite=None, config_id=0, enc=b'', payload=b'', confirmation=None, retry_configs=(), **kwargs)[source]

Make an encrypted_client_hello extension.

data decides the structure when given, msg_type otherwise.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (ECHClientHelloOuter | ECHClientHelloInner | ECHHelloRetryRequest | ECHEncryptedExtensions | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • inner (bool) – Whether a ClientHello carries the inner variant, if data is not given.

  • cipher_suite (HpkeSymmetricCipherSuite | None) – Cipher suite of the outer variant, if data is not given.

  • config_id (int) – config_id of the outer variant, if data is not given.

  • enc (bytes) – Encapsulated key of the outer variant, if data is not given.

  • payload (bytes) – Encrypted payload of the outer variant, if data is not given.

  • confirmation (bytes | None) – Confirmation for a HelloRetryRequest, if data is not given.

  • retry_configs (Iterable[ECHConfig]) – Retry configurations for EncryptedExtensions, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

ECHExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If neither data nor msg_type names a structure, the argument it needs is missing, a confirmation is not 8 octets, or an HPKE identifier, a member or an int code, does not fit in two octets.

_make_ext_renegotiation_info(ext_type, data=None, *, msg_type, renegotiated_connection=b'', **kwargs)[source]

Make a renegotiation_info extension.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (RenegotiationInfo | None) – Decoded extension_data.

  • msg_type (HandshakeType) – Handshake message carrying the extension.

  • renegotiated_connection (bytes) – verify_data of the previous handshake, if data is not given.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

RenegotiationInfoExtension

Returns:

Constructed extension_data schema.

Raises:

ProtocolError – If data is not given for a message other than a ClientHello or ServerHello.

_validate_tls_record(schema, *, available, dtls)[source]

Reject octets that cannot be a genuine TLS/DTLS record.

Dispatch hands this class every payload on its port, most of them mid-stream continuations with no record header. Without this check any octets decode as a record: the content-type registry mints a member for unknown values, and a length past the buffer is zero-padded by FieldBase.unpack.

Parameters:
  • schema (Any) – The just-parsed record header.

  • available (int) – Octets actually available to this layer – the record header plus its fragment, and anything coalesced after it.

  • dtls (bool) – Whether this is a DTLS record, for the legacy-version range it checks.

Raises:

ProtocolError – If schema cannot be a genuine record, so that beholder() degrades dispatch to Raw instead of accepting a fabricated one.

Return type:

None

Note

A record split across TCP segments is rejected too: this layer holds only a fragment of it, and reassembly is TCP’s job.

_tls_negotiates(schema, target, *, dtls)[source]

Whether this record’s first handshake message negotiates target.

A best-effort peek ahead of the real parse: any decoding failure here is reported as “no”, leaving the real parse to raise.

Parameters:
  • schema (Any) – The just-parsed record header.

  • target (int) – The negotiated-version value to look for (TLS13_VERSION or DTLS13_VERSION).

  • dtls (bool) – Whether this is a DTLS record.

Return type:

bool

Returns:

Whether the record’s fragment decodes as cleartext handshake messages whose first one carries a supported_versions extension listing target.

_tls_content_is_cleartext(content_type, fragment, *, dtls, epoch)[source]

Whether a record’s fragment is cleartext to decode structurally.

handshake, alert and change_cipher_spec carry ciphertext once keys are derived, and the record header does not say so. Decoding ciphertext would fabricate content, or fail and lose the cleartext header to Raw.

  • DTLS: epoch 0 is cleartext, any later epoch encrypted (RFC 9147 Section 4.2).

  • TLS: handshake must tile (_tls_handshake_tiles()); alert must be exactly 2 octets and change_cipher_spec exactly 1, which encryption overhead never yields.

Any other content type is reported as not cleartext.

Parameters:
  • content_type (ContentType) – Record content type.

  • fragment (bytes) – Record fragment, undecoded.

  • dtls (bool) – Whether this is a DTLS record.

  • epoch (int) – The DTLS record’s epoch; unused when dtls is false.

Return type:

bool

Returns:

Whether to decode fragment structurally for its content type.

_read_tls_content(content_type, fragment, *, dtls, epoch=0)[source]

Decode a record fragment by its content type.

Parameters:
  • content_type (ContentType) – Record content type.

  • fragment (bytes) – Record fragment, undecoded.

  • dtls (bool) – Whether this is a DTLS record, i.e. whether a handshake message carries DTLS’s fragment header.

  • epoch (int) – The DTLS record’s epoch, which says whether its fragment is encrypted; ignored when dtls is false, since a TLS record header carries no equivalent.

Return type:

Any

Returns:

A tuple of handshake messages for handshake, an Alert for alert, a ChangeCipherSpec for change_cipher_spec, or fragment unchanged for every other content type – application data, heartbeat, ACK, and any content type this version does not name.

Raises:

ProtocolError – If fragment is malformed for content_type.

Notes

handshake, alert and change_cipher_spec are kept as bytes when _tls_content_is_cleartext() says they are encrypted.

_read_tls_handshake_messages(fragment, *, dtls)[source]

Decode a handshake record fragment into its handshake messages.

A record may coalesce several handshake messages.

Parameters:
  • fragment (bytes) – Record fragment, i.e. one or more concatenated handshake messages.

  • dtls (bool) – Whether each message carries DTLS’s fragment header (message_seq, fragment_offset, fragment_length; RFC 6347 Section 4.2.2) after the 4-octet msg_type/length header shared with TLS.

Return type:

tuple[Any, ...]

Returns:

The decoded handshake messages, in order.

Raises:

ProtocolError – If a message’s header or body runs past the end of fragment.

Notes

Only an unfragmented ClientHello, ServerHello or EncryptedExtensions body is decoded; other bodies stay undecoded (#2437). A fragmented DTLS message is decoded once reassembled, by dtls_handshake() (#2440).

_make_tls_handshake_messages(messages, *, dtls)[source]

Encode handshake messages back into a record fragment – the inverse of _read_tls_handshake_messages().

Parameters:
  • messages (tuple[Any, ...]) – Handshake messages, as returned by _read_tls_handshake_messages(), or already-encoded bytes per message. A fragmented DTLS message’s body is its fragment’s octets, or the whole message, of which only the fragment’s range is written.

  • dtls (bool) – Whether to write DTLS’s fragment header after each message’s msg_type/length header.

Return type:

bytes

Returns:

Encoded record fragment.

Raises:

ProtocolError – If a fragmented DTLS message’s body does not yield exactly fragment_length octets, which a fragment carries (RFC 6347 Section 4.2.3).

_read_tls_client_hello(body, *, dtls)[source]

Decode a ClientHello handshake message body.

Structure of TLS’s ClientHello [RFC 9846 Section 4.2.2]:

uint16 ProtocolVersion;
opaque Random[32];

uint8 CipherSuite[2];    /* Cryptographic suite selector */

struct {
    ProtocolVersion legacy_version = 0x0303;    /* TLS v1.2 */
    Random random;
    opaque legacy_session_id<0..32>;
    CipherSuite cipher_suites<2..2^16-2>;
    opaque legacy_compression_methods<1..2^8-1>;
    Extension extensions<7..2^16-1>;
} ClientHello;

DTLS inserts a cookie after legacy_session_id [RFC 6347 Section 4.2.1, RFC 9147 Section 5.3]:

struct {
    ProtocolVersion legacy_version = { 254,253 }; // DTLSv1.2
    Random random;
    opaque legacy_session_id<0..32>;
    opaque legacy_cookie<0..2^8-1>;                  // DTLS
    CipherSuite cipher_suites<2..2^16-2>;
    opaque legacy_compression_methods<1..2^8-1>;
    Extension extensions<8..2^16-1>;
} ClientHello;
Parameters:
  • body (bytes) – Message body.

  • dtls (bool) – Whether this is a DTLS ClientHello, i.e. whether cookie is present.

Return type:

ClientHello

Returns:

Decoded ClientHello.

Raises:

ProtocolError – If body is malformed.

_read_tls_server_hello(body)[source]

Decode a ServerHello handshake message body, or a HelloRetryRequest’s, whose random is _HRR_RANDOM.

Structure of ServerHello [RFC 9846 Section 4.2.3]:

struct {
    ProtocolVersion legacy_version = 0x0303;    /* TLS v1.2 */
    Random random;
    opaque legacy_session_id_echo<0..32>;
    CipherSuite cipher_suite;
    uint8 legacy_compression_method = 0;
    Extension extensions<6..2^16-1>;
} ServerHello;
Parameters:

body (bytes) – Message body.

Return type:

ServerHello

Returns:

Decoded ServerHello.

Raises:

ProtocolError – If body is malformed.

_read_tls_encrypted_extensions(body)[source]

Decode an EncryptedExtensions handshake message body.

Structure of EncryptedExtensions [RFC 9846 Section 4.4.1]:

struct {
    Extension extensions<0..2^16-1>;
} EncryptedExtensions;
Parameters:

body (bytes) – Message body.

Return type:

EncryptedExtensions

Returns:

Decoded EncryptedExtensions.

Raises:

ProtocolError – If body is malformed.

_read_tls_extensions(data, *, msg_type)[source]

Decode an extension list.

Structure of one extension [RFC 9846 Section 4.3]:

struct {
    ExtensionType extension_type;
    opaque extension_data<0..2^16-1>;
} Extension;

Each extension_data is unpacked by the schema Extension registers for its type (_read_ext_schema()), then read by the parser __extension__ registers. The framing delimits it, so one its schema or parser rejects with a ProtocolError is kept as its raw octets rather than failing the message. Both run in a CaughtByCaller block, so that error is quiet: nothing is logged and no exception hook installed.

Parameters:
  • data (bytes) – The extension list, i.e. one or more concatenated extensions, with no further length prefix of its own.

  • msg_type (HandshakeType) – Handshake message carrying the list, which the structure of some extensions depends on; hello_retry_request for a ServerHello that is a HelloRetryRequest.

Return type:

tuple[Extension, ...]

Returns:

The decoded extensions, in order.

Raises:

ProtocolError – If an extension’s header or body runs past the end of data.

_read_ext_schema(ext_type, data, *, msg_type)[source]

Unpack an extension_data by the schema registered for its type.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

  • msg_type (HandshakeType) – Handshake message carrying the extension, which the schema reads as __msg_type__, as it reads _dtls as __dtls__.

Return type:

Extension

Returns:

The schema Extension registers for ext_type, or UnknownExtension.

Raises:

ProtocolError – If data ends inside a field, leaves octets of a vector unread, or holds a vector its items do not tile.

_make_tls_content(content_type, content, *, dtls)[source]

Encode a record fragment by its content type – the inverse of _read_tls_content().

Parameters:
  • content_type (ContentType) – Record content type.

  • content (Any) – Decoded record content, or already-encoded bytes.

  • dtls (bool) – Whether this is a DTLS record.

Return type:

bytes

Returns:

Encoded record fragment.

_make_tls_client_hello(data, *, dtls)[source]

Encode a ClientHello handshake message body – the inverse of _read_tls_client_hello().

Parameters:
  • data (ClientHello) – Decoded ClientHello.

  • dtls (bool) – Whether this is a DTLS ClientHello, i.e. whether to write the cookie field.

Return type:

bytes

Returns:

Encoded message body.

_make_tls_server_hello(data)[source]

Encode a ServerHello handshake message body – the inverse of _read_tls_server_hello().

Parameters:

data (ServerHello) – Decoded ServerHello.

Return type:

bytes

Returns:

Encoded message body.

_make_tls_encrypted_extensions(data)[source]

Encode an EncryptedExtensions handshake message body – the inverse of _read_tls_encrypted_extensions().

Parameters:

data (EncryptedExtensions) – Decoded EncryptedExtensions.

Return type:

bytes

Returns:

Encoded message body.

_make_tls_extensions(extensions, *, msg_type)[source]

Encode an extension list – the inverse of _read_tls_extensions().

Raw extension_data octets are written as they are; anything else goes to the constructor __extension__ registers for the type, which returns the extension_data schema, checked by _make_ext_values() before it is packed.

Parameters:
Return type:

bytes

Returns:

Encoded extension list, with no further length prefix of its own.

Raises:

ProtocolError – If the type of a (type, kwargs) pair is a name, a bool, or a member or code the 16-bit extension type field cannot carry; or if a constructor returns anything but a Schema, as one written for 1.6.x returns bytes.

_make_ext_values(schema)[source]

Check the values of a made extension_data schema fit their fields.

A NumberField masks an out-of-range value when it packs, so each integer, a vector’s length included, is packed by _make_pack() first and stored as the int it packed. Each octet string is stored as the bytes its buffer holds. A ConditionalField whose test the schema’s values fail is absent, and is passed over.

Parameters:

schema (Schema) – The schema, and every schema nested in it.

Raises:
  • StructError – If an integer does not fit in its field.

  • TypeError – If an integer field holds what int cannot convert, None included, or an octet field holds what is not bytes-like.

_make_ext_value(value, size)[source]

Check value fits a size-octet field, as _make_ext_values() does each.

Parameters:
  • value (Any) – The value, or anything int converts to one.

  • size (int) – Octets in the field.

Return type:

int

Returns:

The value as an int.

Raises:

Header Schemas

Added in version 1.7.0.

class pcapkit.protocols.application.ssl.schema.Extension(*args, **kwargs)[source]

Bases: EnumSchema[ExtensionType]

Header schema for the extension_data of a TLS extension.

class pcapkit.protocols.application.ssl.schema.UnknownExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for an extension_data with no structure, kept raw.

data: bytes = <BytesField data>

The octets.

class pcapkit.protocols.application.ssl.schema.Empty(dict_=None, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for struct {} Empty (RFC 9846 Section 3.6).

class pcapkit.protocols.application.ssl.schema.Opaque8(length=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an opaque <..2^8-1> vector item.

length: int = <UInt8Field length>

Length of data.

data: bytes = <BytesField data>

The octets.

class pcapkit.protocols.application.ssl.schema.Opaque16(length=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an opaque <..2^16-1> vector item.

length: int = <UInt16Field length>

Length of data.

data: bytes = <BytesField data>

The octets.

class pcapkit.protocols.application.ssl.schema.ServerName(name_type=NO_VALUE, length=NO_VALUE, name=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a ServerName (RFC 6066 Section 3).

name_type: int = <UInt8Field name_type>

NameType.

length: int = <UInt16Field length>

Length of name.

name: bytes = <BytesField name>

HostName.

class pcapkit.protocols.application.ssl.schema.ServerNameList(length=NO_VALUE, server_name_list=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a ServerNameList (RFC 6066 Section 3).

length: int = <UInt16Field length>

Length of server_name_list.

server_name_list: list[ServerName] = <ListField server_name_list>

Server names.

class pcapkit.protocols.application.ssl.schema.ServerNameExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for server_name (RFC 6066 Section 3).

data: ServerNameList | Empty | bytes = <SwitchField data>

A ServerNameList in a ClientHello, empty in a ServerHello or EncryptedExtensions.

class pcapkit.protocols.application.ssl.schema.OCSPStatusRequest(responder_id_list_length=NO_VALUE, responder_id_list=NO_VALUE, request_extensions_length=NO_VALUE, request_extensions=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an OCSPStatusRequest (RFC 6066 Section 8).

responder_id_list_length: int = <UInt16Field responder_id_list_length>

Length of responder_id_list.

responder_id_list: list[Opaque16] = <ListField responder_id_list>

ResponderID values.

request_extensions_length: int = <UInt16Field request_extensions_length>

Length of request_extensions.

request_extensions: bytes = <BytesField request_extensions>

DER-encoded OCSP request Extensions.

class pcapkit.protocols.application.ssl.schema.CertificateStatusRequest(status_type=NO_VALUE, request=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a CertificateStatusRequest (RFC 6066 Section 8).

status_type: int = <UInt8Field status_type>

CertificateStatusType.

request: OCSPStatusRequest = <ConditionalField request>

The request, for ocsp, the one type it is defined for.

class pcapkit.protocols.application.ssl.schema.StatusRequestExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for status_request.

data: CertificateStatusRequest | Empty | bytes = <SwitchField data>

A CertificateStatusRequest in a ClientHello, empty in a ServerHello.

class pcapkit.protocols.application.ssl.schema.NamedGroupList(length=NO_VALUE, named_group_list=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a NamedGroupList (RFC 9846 Section 4.3.7).

length: int = <UInt16Field length>

Length of named_group_list.

named_group_list: list[int] = <ListField named_group_list>

NamedGroup values.

class pcapkit.protocols.application.ssl.schema.SupportedGroupsExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for supported_groups.

data: NamedGroupList | bytes = <SwitchField data>

A NamedGroupList in a ClientHello or EncryptedExtensions.

class pcapkit.protocols.application.ssl.schema.ECPointFormatList(length=NO_VALUE, ec_point_format_list=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an ECPointFormatList (RFC 8422 Section 5.1.2).

length: int = <UInt8Field length>

Length of ec_point_format_list.

ec_point_format_list: list[int] = <ListField ec_point_format_list>

ECPointFormat values.

class pcapkit.protocols.application.ssl.schema.ECPointFormatsExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for ec_point_formats.

data: ECPointFormatList | bytes = <SwitchField data>

An ECPointFormatList in a ClientHello or ServerHello.

class pcapkit.protocols.application.ssl.schema.SignatureSchemeList(length=NO_VALUE, supported_signature_algorithms=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a SignatureSchemeList (RFC 9846 Section 4.3.3).

length: int = <UInt16Field length>

Length of supported_signature_algorithms.

supported_signature_algorithms: list[int] = <ListField supported_signature_algorithms>

SignatureScheme values.

class pcapkit.protocols.application.ssl.schema.SignatureAlgorithmsExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for signature_algorithms.

data: SignatureSchemeList | bytes = <SwitchField data>

A SignatureSchemeList in a ClientHello or CertificateRequest.

class pcapkit.protocols.application.ssl.schema.ProtocolNameList(length=NO_VALUE, protocol_name_list=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a ProtocolNameList (RFC 7301 Section 3.1).

length: int = <UInt16Field length>

Length of protocol_name_list.

protocol_name_list: list[Opaque8] = <ListField protocol_name_list>

ProtocolName values.

class pcapkit.protocols.application.ssl.schema.ALPNExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for application_layer_protocol_negotiation.

data: ProtocolNameList | bytes = <SwitchField data>

A ProtocolNameList in a ClientHello, ServerHello or EncryptedExtensions.

class pcapkit.protocols.application.ssl.schema.SignedCertificateTimestampList(length=NO_VALUE, sct_list=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a SignedCertificateTimestampList (RFC 6962 Section 3.3).

length: int = <UInt16Field length>

Length of sct_list.

sct_list: list[Opaque16] = <ListField sct_list>

SerializedSCT values.

class pcapkit.protocols.application.ssl.schema.SignedCertificateTimestampExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for signed_certificate_timestamp.

data: SignedCertificateTimestampList | Empty | bytes = <SwitchField data>

Empty in a ClientHello, a SignedCertificateTimestampList in a ServerHello.

class pcapkit.protocols.application.ssl.schema.Padding(padding=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for the padding of RFC 7685 Section 3.

padding: bytes = <BytesField padding>

The padding octets, as captured.

class pcapkit.protocols.application.ssl.schema.PaddingExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for padding.

data: Padding | bytes = <SwitchField data>

The padding in a ClientHello.

class pcapkit.protocols.application.ssl.schema.ExtendedMainSecretExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for extended_main_secret (RFC 7627 Section 5.1).

data: Empty | bytes = <SwitchField data>

Empty in a ClientHello or ServerHello.

class pcapkit.protocols.application.ssl.schema.CertificateCompressionAlgorithms(length=NO_VALUE, algorithms=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a CertificateCompressionAlgorithms (RFC 8879 Section 3).

length: int = <UInt8Field length>

Length of algorithms.

algorithms: list[int] = <ListField algorithms>

CertificateCompressionAlgorithm values.

class pcapkit.protocols.application.ssl.schema.CompressCertificateExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for compress_certificate.

data: CertificateCompressionAlgorithms | bytes = <SwitchField data>

A CertificateCompressionAlgorithms in a ClientHello.

class pcapkit.protocols.application.ssl.schema.RecordSizeLimit(record_size_limit=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a RecordSizeLimit (RFC 8449 Section 4).

record_size_limit: int = <UInt16Field record_size_limit>

Largest record, in octets.

class pcapkit.protocols.application.ssl.schema.RecordSizeLimitExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for record_size_limit.

data: RecordSizeLimit | bytes = <SwitchField data>

A RecordSizeLimit in a ClientHello, ServerHello or EncryptedExtensions.

class pcapkit.protocols.application.ssl.schema.SessionTicket(ticket=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a SessionTicket (RFC 5077 Section 3.2), with no length of its own.

ticket: bytes = <BytesField ticket>

The ticket.

class pcapkit.protocols.application.ssl.schema.SessionTicketExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for session_ticket.

data: SessionTicket | bytes = <SwitchField data>

The ticket in a ClientHello or ServerHello.

class pcapkit.protocols.application.ssl.schema.PskIdentity(length=NO_VALUE, identity=NO_VALUE, obfuscated_ticket_age=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a PskIdentity (RFC 9846 Section 4.3.11).

length: int = <UInt16Field length>

Length of identity.

identity: bytes = <BytesField identity>

The identity.

obfuscated_ticket_age: int = <UInt32Field obfuscated_ticket_age>

Obfuscated ticket age.

class pcapkit.protocols.application.ssl.schema.OfferedPsks(identities_length=NO_VALUE, identities=NO_VALUE, binders_length=NO_VALUE, binders=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an OfferedPsks (RFC 9846 Section 4.3.11).

identities_length: int = <UInt16Field identities_length>

Length of identities.

identities: list[PskIdentity] = <ListField identities>

The identities.

binders_length: int = <UInt16Field binders_length>

Length of binders.

binders: list[Opaque8] = <ListField binders>

PskBinderEntry values.

class pcapkit.protocols.application.ssl.schema.PreSharedKeyServerHello(selected_identity=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a ServerHello’s pre_shared_key (RFC 9846 Section 4.3.11).

selected_identity: int = <UInt16Field selected_identity>

Index of the identity selected.

class pcapkit.protocols.application.ssl.schema.PreSharedKeyExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for pre_shared_key, a PreSharedKeyExtension.

data: OfferedPsks | PreSharedKeyServerHello | bytes = <SwitchField data>

An OfferedPsks in a ClientHello, the selection in a ServerHello.

class pcapkit.protocols.application.ssl.schema.EarlyDataExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for early_data, an EarlyDataIndication (RFC 9846 Section 4.3.10).

data: Empty | bytes = <SwitchField data>

Empty in a ClientHello or EncryptedExtensions.

class pcapkit.protocols.application.ssl.schema.SupportedVersionsClientHello(length=NO_VALUE, versions=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a ClientHello’s supported_versions (RFC 9846 Section 4.3.1).

length: int = <UInt8Field length>

Length of versions.

versions: list[int] = <ListField versions>

ProtocolVersion values.

class pcapkit.protocols.application.ssl.schema.SupportedVersionsServerHello(selected_version=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a ServerHello’s supported_versions (RFC 9846 Section 4.3.1).

selected_version: int = <UInt16Field selected_version>

ProtocolVersion selected.

class pcapkit.protocols.application.ssl.schema.SupportedVersionsExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for supported_versions, a SupportedVersions.

data: SupportedVersionsClientHello | SupportedVersionsServerHello | bytes = <SwitchField data>

The versions in a ClientHello, the selection in a ServerHello or HelloRetryRequest.

class pcapkit.protocols.application.ssl.schema.Cookie(length=NO_VALUE, cookie=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a Cookie (RFC 9846 Section 4.3.2).

length: int = <UInt16Field length>

Length of cookie.

cookie: bytes = <BytesField cookie>

The cookie.

class pcapkit.protocols.application.ssl.schema.CookieExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for cookie.

data: Cookie | bytes = <SwitchField data>

A Cookie in a ClientHello or HelloRetryRequest.

class pcapkit.protocols.application.ssl.schema.PskKeyExchangeModes(length=NO_VALUE, ke_modes=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a PskKeyExchangeModes (RFC 9846 Section 4.3.9).

length: int = <UInt8Field length>

Length of ke_modes.

ke_modes: list[int] = <ListField ke_modes>

PskKeyExchangeMode values.

class pcapkit.protocols.application.ssl.schema.PskKeyExchangeModesExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for psk_key_exchange_modes.

data: PskKeyExchangeModes | bytes = <SwitchField data>

A PskKeyExchangeModes in a ClientHello.

class pcapkit.protocols.application.ssl.schema.PostHandshakeAuthExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for post_handshake_auth (RFC 9846 Section 4.3.6).

data: Empty | bytes = <SwitchField data>

Empty in a ClientHello.

class pcapkit.protocols.application.ssl.schema.KeyShareEntry(group=NO_VALUE, length=NO_VALUE, key_exchange=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a KeyShareEntry (RFC 9846 Section 4.3.8).

group: int = <UInt16Field group>

NamedGroup.

length: int = <UInt16Field length>

Length of key_exchange.

key_exchange: bytes = <BytesField key_exchange>

Key exchange information.

class pcapkit.protocols.application.ssl.schema.KeyShareClientHello(length=NO_VALUE, client_shares=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a KeyShareClientHello (RFC 9846 Section 4.3.8).

length: int = <UInt16Field length>

Length of client_shares.

client_shares: list[KeyShareEntry] = <ListField client_shares>

Key shares offered.

class pcapkit.protocols.application.ssl.schema.KeyShareHelloRetryRequest(selected_group=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a KeyShareHelloRetryRequest (RFC 9846 Section 4.3.8).

selected_group: int = <UInt16Field selected_group>

NamedGroup selected.

class pcapkit.protocols.application.ssl.schema.KeyShareServerHello(server_share=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a KeyShareServerHello (RFC 9846 Section 4.3.8).

server_share: KeyShareEntry = <SchemaField server_share>

Key share selected.

class pcapkit.protocols.application.ssl.schema.KeyShareExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for key_share.

data: KeyShareClientHello | KeyShareHelloRetryRequest | KeyShareServerHello | bytes = <SwitchField data>

The structure of a ClientHello, HelloRetryRequest or ServerHello.

class pcapkit.protocols.application.ssl.schema.ConnectionId(length=NO_VALUE, cid=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a ConnectionId (RFC 9146 Section 3).

length: int = <UInt8Field length>

Length of cid.

cid: bytes = <BytesField cid>

The connection ID.

class pcapkit.protocols.application.ssl.schema.ConnectionIdExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for connection_id.

data: ConnectionId | bytes = <SwitchField data>

A ConnectionId in a DTLS ClientHello or ServerHello.

class pcapkit.protocols.application.ssl.schema.HpkeSymmetricCipherSuite(kdf_id=NO_VALUE, aead_id=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an HpkeSymmetricCipherSuite (RFC 9849 Section 4).

kdf_id: HpkeKdfId = <EnumField kdf_id>

HpkeKdfId.

aead_id: HpkeAeadId = <EnumField aead_id>

HpkeAeadId.

class pcapkit.protocols.application.ssl.schema.ECHClientHello(type=NO_VALUE, cipher_suite=NO_VALUE, config_id=NO_VALUE, enc_length=NO_VALUE, enc=NO_VALUE, payload_length=NO_VALUE, payload=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an ECHClientHello (RFC 9849 Section 5).

type: int = <UInt8Field type>

Client hello type, ECHClientHelloType, outer (0) or inner (1).

cipher_suite: HpkeSymmetricCipherSuite = <ConditionalField cipher_suite>

Cipher suite, for outer.

config_id: int = <ConditionalField config_id>

config_id, for outer.

enc_length: int = <ConditionalField enc_length>

Length of enc, for outer.

enc: bytes = <ConditionalField enc>

Encapsulated key, for outer.

payload_length: int = <ConditionalField payload_length>

Length of payload, for outer.

payload: bytes = <ConditionalField payload>

Encrypted payload, for outer.

class pcapkit.protocols.application.ssl.schema.ECHHelloRetryRequest(confirmation=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an ECHHelloRetryRequest (RFC 9849 Section 5).

confirmation: bytes = <BytesField confirmation>

Acceptance confirmation.

class pcapkit.protocols.application.ssl.schema.ECHConfigExtension(type=NO_VALUE, length=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an ECHConfigExtension (RFC 9849 Section 4).

type: int = <UInt16Field type>

ECHConfigExtensionType.

length: int = <UInt16Field length>

Length of data.

data: bytes = <BytesField data>

Extension data.

class pcapkit.protocols.application.ssl.schema.ECHConfigContents(config_id=NO_VALUE, kem_id=NO_VALUE, public_key_length=NO_VALUE, public_key=NO_VALUE, cipher_suites_length=NO_VALUE, cipher_suites=NO_VALUE, maximum_name_length=NO_VALUE, public_name_length=NO_VALUE, public_name=NO_VALUE, extensions_length=NO_VALUE, extensions=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an ECHConfigContents (RFC 9849 Section 4), its HpkeKeyConfig inline, since that has no length of its own.

config_id: int = <UInt8Field config_id>

config_id of the HpkeKeyConfig.

kem_id: HpkeKemId = <EnumField kem_id>

HpkeKemId of the HpkeKeyConfig.

public_key_length: int = <UInt16Field public_key_length>

Length of public_key.

public_key: bytes = <BytesField public_key>

HpkePublicKey of the HpkeKeyConfig.

cipher_suites_length: int = <UInt16Field cipher_suites_length>

Length of cipher_suites.

cipher_suites: list[HpkeSymmetricCipherSuite] = <ListField cipher_suites>

Cipher suites of the HpkeKeyConfig.

maximum_name_length: int = <UInt8Field maximum_name_length>

Longest name the client may pad its inner name to.

public_name_length: int = <UInt8Field public_name_length>

Length of public_name.

public_name: bytes = <BytesField public_name>

Public name.

extensions_length: int = <UInt16Field extensions_length>

Length of extensions.

extensions: list[ECHConfigExtension] = <ListField extensions>

Configuration extensions.

class pcapkit.protocols.application.ssl.schema.ECHConfig(version=NO_VALUE, length=NO_VALUE, contents=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an ECHConfig (RFC 9849 Section 4).

version: int = <UInt16Field version>

Version.

length: int = <UInt16Field length>

Length of contents.

contents: ECHConfigContents | bytes = <SwitchField contents>

The contents of version 0xFE0D; the raw octets of any other.

class pcapkit.protocols.application.ssl.schema.ECHEncryptedExtensions(length=NO_VALUE, retry_configs=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for an ECHEncryptedExtensions (RFC 9849 Section 5).

length: int = <UInt16Field length>

Length of retry_configs.

retry_configs: list[ECHConfig] = <ListField retry_configs>

Retry configurations, an ECHConfigList.

class pcapkit.protocols.application.ssl.schema.ECHExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for encrypted_client_hello.

data: ECHClientHello | ECHHelloRetryRequest | ECHEncryptedExtensions | bytes = <SwitchField data>

An ECHClientHello, ECHHelloRetryRequest or ECHEncryptedExtensions.

class pcapkit.protocols.application.ssl.schema.RenegotiationInfo(length=NO_VALUE, renegotiated_connection=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Schema

Header schema for a RenegotiationInfo (RFC 5746 Section 3.2).

length: int = <UInt8Field length>

Length of renegotiated_connection.

renegotiated_connection: bytes = <BytesField renegotiated_connection>

verify_data of the previous handshake.

class pcapkit.protocols.application.ssl.schema.RenegotiationInfoExtension(data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: Extension

Header schema for renegotiation_info.

data: RenegotiationInfo | bytes = <SwitchField data>

A RenegotiationInfo in a ClientHello or ServerHello.

Data Models

class pcapkit.protocols.application.ssl.data.Handshake(*args, **kwargs)[source]

Bases: Data

Data model for a TLS/DTLS handshake message.

body holds a ClientHello, ServerHello or EncryptedExtensions for those message types, and the raw, undecoded message body for every other HandshakeType – message-TYPE-level framing only (#2437).

msg_type: HandshakeType

Handshake message type.

length: int

Message length (24-bit), the 4-octet handshake header excluded.

body: ClientHello | ServerHello | EncryptedExtensions | bytes

Message body.

class pcapkit.protocols.application.ssl.data.ClientHello(version, random, session_id, cookie, cipher_suites, compression_methods, extensions)[source]

Bases: Data

Data model for a TLS/DTLS ClientHello handshake message body.

version: int

Client (legacy) version.

random: bytes

Client random (32 octets).

session_id: bytes

Session ID.

cookie: bytes | None

DTLS’s cookie (RFC 6347 Section 4.2.1; carried forward as legacy_cookie by RFC 9147 Section 5.3), or None for TLS, whose ClientHello carries no cookie field at all – distinct from DTLS’s empty cookie, which is b''.

cipher_suites: tuple[int, ...]

Cipher suites offered.

compression_methods: tuple[int, ...]

Compression methods offered.

extensions: tuple[Extension, ...] | None

Extensions, or None when the message carries no extensions field at all – distinct from an empty extension list, which is ().

class pcapkit.protocols.application.ssl.data.ServerHello(version, random, session_id, cipher_suite, compression_method, extensions)[source]

Bases: Data

Data model for a TLS/DTLS ServerHello handshake message body.

A HelloRetryRequest shares the structure and is told apart by its random (RFC 9846 Section 4.2.3); its extensions decode in the shapes a HelloRetryRequest gives them.

version: int

Server (legacy) version.

random: bytes

Server random (32 octets).

session_id: bytes

Session ID.

cipher_suite: int

Cipher suite selected.

compression_method: int

Compression method selected.

extensions: tuple[Extension, ...] | None

Extensions, or None when the message carries no extensions field at all – distinct from an empty extension list, which is ().

class pcapkit.protocols.application.ssl.data.EncryptedExtensions(extensions)[source]

Bases: Data

Data model for a TLS/DTLS EncryptedExtensions handshake message body (RFC 9846 Section 4.4.1).

extensions: tuple[Extension, ...]

Extensions.

class pcapkit.protocols.application.ssl.data.Extension(type, data)[source]

Bases: Data

Data model for a TLS/DTLS extension list entry (RFC 9846 Section 4.3).

data holds the decoded extension_data where SSL.__extension__ registers a decoder for type, and the raw octets otherwise – including a body its decoder cannot read exactly, or one in a message whose structure for it the decoder does not know.

type: ExtensionType

Extension type.

data: ExtensionData | bytes

Extension data – decoded, or the raw octets.

class pcapkit.protocols.application.ssl.data.ExtensionData(*args, **kwargs)[source]

Bases: Data

Data model for a decoded TLS/DTLS extension_data field.

Each subclass is a structure an ExtensionType carries, named as its specification names it; Empty serves every type whose extension_data is empty.

class pcapkit.protocols.application.ssl.data.ServerNameList(server_name_list)[source]

Bases: ExtensionData

Data model for the server_name extension (RFC 6066 Section 3).

A ServerHello or EncryptedExtensions carries the extension with empty extension_data, which stays b''.

server_name_list: tuple[ServerName, ...]

Server names.

class pcapkit.protocols.application.ssl.data.ServerName(name_type, name)[source]

Bases: Data

Data model for one ServerName of a server_name extension (RFC 6066 Section 3).

name_type: int

Name type; 0 is host_name, the only one defined.

name: bytes

Name, i.e. the HostName octets.

class pcapkit.protocols.application.ssl.data.NamedGroupList(named_group_list)[source]

Bases: ExtensionData

Data model for the supported_groups extension (RFC 9846 Section 4.3.7).

named_group_list: tuple[int, ...]

NamedGroup values, most preferred first.

class pcapkit.protocols.application.ssl.data.SignatureSchemeList(supported_signature_algorithms)[source]

Bases: ExtensionData

Data model for the signature_algorithms extension (RFC 9846 Section 4.3.3).

supported_signature_algorithms: tuple[int, ...]

SignatureScheme values, most preferred first.

class pcapkit.protocols.application.ssl.data.ProtocolNameList(protocol_name_list)[source]

Bases: ExtensionData

Data model for the application_layer_protocol_negotiation extension (RFC 7301 Section 3.1).

protocol_name_list: tuple[bytes, ...]

ProtocolName octet strings, e.g. b'h2'.

class pcapkit.protocols.application.ssl.data.SupportedVersionsClientHello(versions)[source]

Bases: ExtensionData

Data model for a ClientHello’s supported_versions extension (RFC 9846 Section 4.3.1).

versions: tuple[int, ...]

ProtocolVersion values, most preferred first.

class pcapkit.protocols.application.ssl.data.SupportedVersionsServerHello(selected_version)[source]

Bases: ExtensionData

Data model for a ServerHello’s or HelloRetryRequest’s supported_versions extension (RFC 9846 Section 4.3.1).

selected_version: int

The ProtocolVersion selected.

class pcapkit.protocols.application.ssl.data.KeyShareClientHello(client_shares)[source]

Bases: ExtensionData

Data model for a ClientHello’s key_share extension (RFC 9846 Section 4.3.8).

client_shares: tuple[KeyShareEntry, ...]

Key shares offered, most preferred first.

class pcapkit.protocols.application.ssl.data.KeyShareHelloRetryRequest(selected_group)[source]

Bases: ExtensionData

Data model for a HelloRetryRequest’s key_share extension (RFC 9846 Section 4.3.8).

selected_group: int

NamedGroup the server asks a retried ClientHello to share.

class pcapkit.protocols.application.ssl.data.KeyShareServerHello(server_share)[source]

Bases: ExtensionData

Data model for a ServerHello’s key_share extension (RFC 9846 Section 4.3.8).

server_share: KeyShareEntry

The server’s key share.

class pcapkit.protocols.application.ssl.data.KeyShareEntry(group, key_exchange)[source]

Bases: Data

Data model for one KeyShareEntry of a key_share extension (RFC 9846 Section 4.3.8).

group: int

NamedGroup of the key.

key_exchange: bytes

Key exchange information.

class pcapkit.protocols.application.ssl.data.ConnectionId(cid)[source]

Bases: ExtensionData

Data model for the connection_id extension (RFC 9146 Section 3).

The extension is DTLS-only (RFC 9146 Section 10.2); a TLS hello that carries it, which does not conform, decodes to this model all the same.

cid: bytes

The connection ID its sender wants to receive; empty when it wants none.

class pcapkit.protocols.application.ssl.data.Empty(dict_=None, **kwargs)[source]

Bases: ExtensionData

Data model for an extension_data that is empty in the message carrying it, the Empty structure of RFC 9846 Section 4.3.10.

extended_main_secret (RFC 7627 Section 5.1) and post_handshake_auth (RFC 9846 Section 4.3.6) are always empty, early_data in a ClientHello and EncryptedExtensions (RFC 9846 Section 4.3.10), signed_certificate_timestamp in a ClientHello (RFC 6962 Section 3.3.1), and status_request in a ServerHello (RFC 6066 Section 8).

Added in version 1.7.0.

class pcapkit.protocols.application.ssl.data.CertificateStatusRequest(status_type, request)[source]

Bases: ExtensionData

Data model for a ClientHello’s status_request extension (RFC 6066 Section 8).

Only ocsp has a request structure, so a body naming another status_type stays raw octets.

Added in version 1.7.0.

status_type: CertificateStatusType

Status type.

request: OCSPStatusRequest

The OCSP request.

class pcapkit.protocols.application.ssl.data.OCSPStatusRequest(responder_id_list, request_extensions)[source]

Bases: Data

Data model for the OCSPStatusRequest of a status_request extension (RFC 6066 Section 8).

Added in version 1.7.0.

responder_id_list: tuple[bytes, ...]

DER-encoded ResponderID values; empty when the server knows the responders.

request_extensions: bytes

DER-encoded OCSP request Extensions; empty for none.

class pcapkit.protocols.application.ssl.data.ECPointFormatList(ec_point_format_list)[source]

Bases: ExtensionData

Data model for the ec_point_formats extension (RFC 8422 Section 5.1.2).

Added in version 1.7.0.

ec_point_format_list: tuple[ECPointFormat, ...]

Point formats, most preferred first.

class pcapkit.protocols.application.ssl.data.SignedCertificateTimestampList(sct_list)[source]

Bases: ExtensionData

Data model for a ServerHello’s signed_certificate_timestamp extension (RFC 6962 Section 3.3).

Added in version 1.7.0.

sct_list: tuple[bytes, ...]

SerializedSCT octet strings.

class pcapkit.protocols.application.ssl.data.Padding(padding)[source]

Bases: ExtensionData

Data model for the padding extension (RFC 7685 Section 3).

Added in version 1.7.0.

padding: bytes

Padding octets as captured, which RFC 7685 Section 3 requires to be zero.

class pcapkit.protocols.application.ssl.data.CertificateCompressionAlgorithms(algorithms)[source]

Bases: ExtensionData

Data model for the compress_certificate extension (RFC 8879 Section 3).

Added in version 1.7.0.

algorithms: tuple[CertificateCompressionAlgorithm, ...]

Compression algorithms, most preferred first.

class pcapkit.protocols.application.ssl.data.RecordSizeLimit(record_size_limit)[source]

Bases: ExtensionData

Data model for the record_size_limit extension (RFC 8449 Section 4).

Added in version 1.7.0.

record_size_limit: int

Largest record, in octets, the sender is willing to receive.

class pcapkit.protocols.application.ssl.data.SessionTicket(ticket)[source]

Bases: ExtensionData

Data model for the session_ticket extension (RFC 5077 Section 3.2).

Added in version 1.7.0.

ticket: bytes

The ticket; empty when the client has none to offer, and in a ServerHello.

class pcapkit.protocols.application.ssl.data.OfferedPsks(identities, binders)[source]

Bases: ExtensionData

Data model for a ClientHello’s pre_shared_key extension (RFC 9846 Section 4.3.11).

Added in version 1.7.0.

identities: tuple[PskIdentity, ...]

Identities offered.

binders: tuple[bytes, ...]

PskBinderEntry HMAC values, one per identity.

class pcapkit.protocols.application.ssl.data.PskIdentity(identity, obfuscated_ticket_age)[source]

Bases: Data

Data model for one PskIdentity of a pre_shared_key extension (RFC 9846 Section 4.3.11).

Added in version 1.7.0.

identity: bytes

Label of the key, e.g. a ticket.

obfuscated_ticket_age: int

Obfuscated age of the key.

class pcapkit.protocols.application.ssl.data.PreSharedKeyServerHello(selected_identity)[source]

Bases: ExtensionData

Data model for a ServerHello’s pre_shared_key extension (RFC 9846 Section 4.3.11).

Added in version 1.7.0.

selected_identity: int

Index of the identity selected, into the ClientHello’s list.

class pcapkit.protocols.application.ssl.data.Cookie(cookie)[source]

Bases: ExtensionData

Data model for the cookie extension (RFC 9846 Section 4.3.2).

Added in version 1.7.0.

cookie: bytes

The cookie, which a ClientHello copies from the HelloRetryRequest.

class pcapkit.protocols.application.ssl.data.PskKeyExchangeModes(ke_modes)[source]

Bases: ExtensionData

Data model for the psk_key_exchange_modes extension (RFC 9846 Section 4.3.9).

Added in version 1.7.0.

ke_modes: tuple[PskKeyExchangeMode, ...]

Key exchange modes the client supports with a PSK.

class pcapkit.protocols.application.ssl.data.ECHClientHelloOuter(cipher_suite, config_id, enc, payload)[source]

Bases: ExtensionData

Data model for the outer variant of a ClientHello’s encrypted_client_hello extension (RFC 9849 Section 5).

Added in version 1.7.0.

cipher_suite: HpkeSymmetricCipherSuite

Cipher suite encrypting the inner ClientHello.

config_id: int

config_id of the ECHConfig chosen.

enc: bytes

HPKE encapsulated key; empty after a HelloRetryRequest.

payload: bytes

Encrypted EncodedClientHelloInner.

class pcapkit.protocols.application.ssl.data.ECHClientHelloInner(dict_=None, **kwargs)[source]

Bases: ExtensionData

Data model for the inner variant of a ClientHello’s encrypted_client_hello extension (RFC 9849 Section 5), which carries its type alone.

Added in version 1.7.0.

class pcapkit.protocols.application.ssl.data.ECHHelloRetryRequest(confirmation)[source]

Bases: ExtensionData

Data model for a HelloRetryRequest’s encrypted_client_hello extension (RFC 9849 Section 5).

Added in version 1.7.0.

confirmation: bytes

Acceptance confirmation (8 octets).

class pcapkit.protocols.application.ssl.data.ECHEncryptedExtensions(retry_configs)[source]

Bases: ExtensionData

Data model for an EncryptedExtensions’ encrypted_client_hello extension (RFC 9849 Section 5).

Added in version 1.7.0.

retry_configs: tuple[ECHConfig, ...]

The server’s retry configurations, most preferred first.

class pcapkit.protocols.application.ssl.data.ECHConfig(version, contents)[source]

Bases: Data

Data model for one ECHConfig of an ECHConfigList (RFC 9849 Section 4).

Added in version 1.7.0.

version: int

ECH version of the configuration.

contents: ECHConfigContents | bytes

The decoded contents for the version RFC 9849 defines, 0xFE0D, and the raw octets for any other, which a client skips.

class pcapkit.protocols.application.ssl.data.ECHConfigContents(key_config, maximum_name_length, public_name, extensions)[source]

Bases: Data

Data model for the ECHConfigContents of an ECHConfig (RFC 9849 Section 4).

Added in version 1.7.0.

key_config: HpkeKeyConfig

HPKE key configuration.

maximum_name_length: int

Longest name of a backend server, or 0 if not known.

public_name: bytes

DNS name of the client-facing server.

extensions: tuple[ECHConfigExtension, ...]

Configuration extensions.

class pcapkit.protocols.application.ssl.data.HpkeKeyConfig(config_id, kem_id, public_key, cipher_suites)[source]

Bases: Data

Data model for the HpkeKeyConfig of an ECHConfig (RFC 9849 Section 4).

Added in version 1.7.0.

config_id: int

Identifier of the configuration.

kem_id: HpkeKemId

HPKE KEM identifier (RFC 9180 Section 7.1).

public_key: bytes

HPKE public key.

cipher_suites: tuple[HpkeSymmetricCipherSuite, ...]

Cipher suites a client may encrypt with.

class pcapkit.protocols.application.ssl.data.HpkeSymmetricCipherSuite(kdf_id, aead_id)[source]

Bases: Data

Data model for an HpkeSymmetricCipherSuite (RFC 9849 Section 4).

Added in version 1.7.0.

kdf_id: HpkeKdfId

HPKE KDF identifier (RFC 9180 Section 7.2).

aead_id: HpkeAeadId

HPKE AEAD identifier (RFC 9180 Section 7.3).

class pcapkit.protocols.application.ssl.data.ECHConfigExtension(type, data)[source]

Bases: Data

Data model for one ECHConfigExtension of an ECHConfig (RFC 9849 Section 4.2).

Added in version 1.7.0.

type: int

ECHConfigExtensionType.

data: bytes

Extension data.

class pcapkit.protocols.application.ssl.data.RenegotiationInfo(renegotiated_connection)[source]

Bases: ExtensionData

Data model for the renegotiation_info extension (RFC 5746 Section 3.2).

Added in version 1.7.0.

renegotiated_connection: bytes

verify_data of the previous handshake; empty on an initial one.

class pcapkit.protocols.application.ssl.data.Alert(level, description)[source]

Bases: Data

Data model for a TLS/DTLS Alert record.

level: int

Alert level.

description: int

Alert description.

class pcapkit.protocols.application.ssl.data.ChangeCipherSpec(msg)[source]

Bases: Data

Data model for a TLS/DTLS ChangeCipherSpec record.

msg: int

change_cipher_spec message (always 1 on the wire).

Constants

Added in version 1.7.0.

pcapkit.protocols.application.ssl.const.TLS13_VERSION = 772

The supported_versions value for TLS 1.3 (RFC 9846 Section 4.3.1).

pcapkit.protocols.application.ssl.const.DTLS13_VERSION = 65276

The supported_versions value for DTLS 1.3 (RFC 9147 Section 5.3).

pcapkit.protocols.application.ssl.const._HRR_RANDOM

The random that makes a ServerHello a HelloRetryRequest – the SHA-256 of "HelloRetryRequest" (RFC 9846 Section 4.2.3).

Footnotes