SSL - Secure Sockets Layer

pcapkit.protocols.application.ssl contains SSL only, 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 the two share – content-type dispatch, handshake-message decoding (including the DTLS fragment header), the extension registry, and the record-level validation that keeps dispatch from accepting bytes that cannot be a genuine record.

Added in version 1.6.0.


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

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

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

The extension_data of these extensions decodes, in ClientHello, ServerHello, HelloRetryRequest and EncryptedExtensions:

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).

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

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

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

bytes

Returns:

data unchanged.

_read_ext_server_name(ext_type, data, *, 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;
Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

ServerNameList | bytes

Returns:

The decoded list; or data when empty, as a ServerHello’s and an EncryptedExtensions’ are.

Raises:

ProtocolError – If data is malformed, or names a type other than host_name, whose name has no defined structure.

_read_ext_supported_groups(ext_type, data, *, 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:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

NamedGroupList

Returns:

The decoded list.

Raises:

ProtocolError – If data is malformed.

_read_ext_signature_algorithms(ext_type, data, *, 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:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

SignatureSchemeList

Returns:

The decoded list.

Raises:

ProtocolError – If data is malformed.

_read_ext_alpn(ext_type, data, *, 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;
Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

ProtocolNameList

Returns:

The decoded list.

Raises:

ProtocolError – If data is malformed.

_read_ext_supported_versions(ext_type, data, *, 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:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

SupportedVersionsClientHello | SupportedVersionsServerHello | bytes

Returns:

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

Raises:

ProtocolError – If data is malformed.

_read_ext_key_share(ext_type, data, *, 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:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

KeyShareClientHello | KeyShareHelloRetryRequest | KeyShareServerHello | bytes

Returns:

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

Raises:

ProtocolError – If data is malformed.

_read_ext_connection_id(ext_type, data, *, 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 (RFC 9146 Section 10.2). A TLS hello carrying it does not conform, and it decodes all the same.

Parameters:
  • ext_type (ExtensionType) – Extension type.

  • data (bytes) – extension_data octets.

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

Return type:

ConnectionId

Returns:

The decoded connection ID.

Raises:

ProtocolError – If data is malformed.

_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:

bytes

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.

Parameters:
Return type:

bytes

Returns:

Constructed extension_data.

_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:

bytes

Returns:

Constructed extension_data.

_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:

bytes

Returns:

Constructed extension_data.

_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:

bytes

Returns:

Constructed extension_data.

_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:

bytes

Returns:

Constructed extension_data.

Raises:

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

_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:

bytes

Returns:

Constructed extension_data.

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:

bytes

Returns:

Constructed extension_data.

_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_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.

_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.

_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.

_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.

_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.

_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.

_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.

_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.

_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 read by the parser __extension__ registers for its type. The framing delimits it, so one its parser rejects with a ProtocolError is kept as its raw octets rather than failing the message. The parser runs 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.

_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.

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.

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

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.

Data Models

class pcapkit.protocols.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.ExtensionData(*args, **kwargs)[source]

Bases: Data

Data model for a decoded TLS/DTLS extension_data field.

Each subclass is the structure one ExtensionType carries, named as its specification names it.

class pcapkit.protocols.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.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.data.application.tls.ChangeCipherSpec(msg)[source]

Bases: Data

Data model for a TLS/DTLS ChangeCipherSpec record.

msg: int

change_cipher_spec message (always 1 on the wire).

Footnotes