Source code for pcapkit.protocols.application.ssl.schema

# -*- coding: utf-8 -*-
# mypy: disable-error-code=assignment
"""header schema for the TLS extensions the SSL family shares

:class:`Extension` is the layout of an ``extension_data`` field
(:rfc:`9846#section-4.3`), registered under its
:class:`~pcapkit.const.tls.extension_type.ExtensionType`. A layout that
differs by handshake message holds it in :attr:`~ServerNameExtension.data`,
chosen by the message the extension is read in: the schema of that message's
structure, or the raw octets in one its RFC defines no structure for, as in a
TLS record for a DTLS-only type. With :envvar:`PCAPKIT_MIMIC` at ``wireshark``,
the message chooses as Wireshark's ``ssl_dissect_hnd_extension`` reads it
(:ref:`mimic-mode`).

"""

from typing import TYPE_CHECKING

from pcapkit.const.tls.extension_type import ExtensionType as Enum_ExtensionType
from pcapkit.const.tls.handshake_type import HandshakeType as Enum_HandshakeType
from pcapkit.const.tls.hpke_aead_id import HpkeAeadId as Enum_HpkeAeadId
from pcapkit.const.tls.hpke_kdf_id import HpkeKdfId as Enum_HpkeKdfId
from pcapkit.const.tls.hpke_kem_id import HpkeKemId as Enum_HpkeKemId
from pcapkit.corekit.fields.collections import ListField
from pcapkit.corekit.fields.misc import ConditionalField, SchemaField, SwitchField
from pcapkit.corekit.fields.numbers import (EnumField, NumberField, UInt8Field, UInt16Field,
                                            UInt32Field)
from pcapkit.corekit.fields.strings import BytesField
from pcapkit.protocols.application.ssl.const import (_ECH_CONFIG_VERSION, _ECH_CONFIRMATION_LENGTH,
                                                     _WIRESHARK_MESSAGES)
from pcapkit.protocols.schema import EnumSchema, Schema, schema_final
from pcapkit.utilities import config

__all__ = [
    'Extension', 'UnknownExtension', 'Empty', 'Opaque8', 'Opaque16',
    'ServerName', 'ServerNameList', 'ServerNameExtension',
    'OCSPStatusRequest', 'CertificateStatusRequest', 'CertificateStatus', 'StatusRequestExtension',
    'NamedGroupList', 'SupportedGroupsExtension', 'ECPointFormatList', 'ECPointFormatsExtension',
    'SignatureSchemeList', 'SignatureAlgorithmsExtension', 'ProtocolNameList', 'ALPNExtension',
    'SignedCertificateTimestampList', 'SignedCertificateTimestampExtension',
    'Padding', 'PaddingExtension', 'ExtendedMainSecretExtension',
    'CertificateCompressionAlgorithms', 'CompressCertificateExtension',
    'RecordSizeLimit', 'RecordSizeLimitExtension',
    'SessionTicket', 'SessionTicketExtension',
    'PskIdentity', 'OfferedPsks', 'PreSharedKeyServerHello', 'PreSharedKeyExtension',
    'EarlyDataNewSessionTicket', 'EarlyDataExtension',
    'SupportedVersionsClientHello', 'SupportedVersionsServerHello', 'SupportedVersionsExtension',
    'Cookie', 'CookieExtension', 'PskKeyExchangeModes', 'PskKeyExchangeModesExtension',
    'PostHandshakeAuthExtension',
    'KeyShareEntry', 'KeyShareClientHello', 'KeyShareHelloRetryRequest', 'KeyShareServerHello',
    'KeyShareExtension', 'ConnectionId', 'ConnectionIdExtension',
    'HpkeSymmetricCipherSuite', 'ECHClientHello', 'ECHHelloRetryRequest', 'ECHConfigExtension',
    'ECHConfigContents', 'ECHConfig', 'ECHEncryptedExtensions', 'ECHExtension',
    'RenegotiationInfo', 'RenegotiationInfoExtension',
]

if TYPE_CHECKING:
    from typing import Any, ClassVar, Optional, Type

    from pcapkit.corekit.fields.field import FieldBase


def _item(schema: 'Type[Schema]') -> 'SchemaField':
    """An item of a vector of ``schema`` structures.

    Args:
        schema: Layout of the item.

    Returns:
        A field reading the item up to the end of its vector at most, so an item
        the vector ends inside records the cut rather than warns.

    """
    return SchemaField(schema=schema, packet={'__data_end__': True})


def _wireshark(other: 'Optional[Type[Schema]]',
               **messages: 'Optional[Type[Schema]]') -> 'dict[int, Optional[Type[Schema]]]':
    """The structure of an ``extension_data`` in each of :data:`_WIRESHARK_MESSAGES`,
    as the ``case`` of ``ssl_dissect_hnd_extension`` for its type reads it.

    Args:
        other: Structure in the messages ``messages`` leaves out: the type's own
            where its ``case`` reads it in any message, or :class:`Empty` where
            it reads nothing, since ``ssl_end_vector`` then flags any octet left.
        **messages: Structures by
            :class:`~pcapkit.const.tls.handshake_type.HandshakeType` name;
            :data:`None` where Wireshark reads one this module has no schema for.

    Returns:
        The structures, by message code.

    """
    table = {int(message): other for message in _WIRESHARK_MESSAGES}  # type: dict[int, Optional[Type[Schema]]]
    table.update({int(getattr(Enum_HandshakeType, name)): value for name, value in messages.items()})
    return table


class _Structures:
    """The structures of an ``extension_data`` by handshake message, and the
    :class:`~pcapkit.corekit.fields.misc.SwitchField` selector that reads them.

    Args:
        rfc: Structures by message code, where the extension's RFC defines one.
        dtls_only: Whether only a DTLS record carries one of ``rfc``, as for a
            type the IANA registry marks DTLS-only (:rfc:`9146#section-10.1`).
        wireshark: Structures by message code with
            :data:`~pcapkit.utilities.config.MIMIC` at ``'wireshark'``, from
            :func:`_wireshark`, in a TLS record, and in a DTLS one unless
            ``wireshark_dtls`` is given.
        wireshark_dtls: Structures in a DTLS record, from :func:`_wireshark`,
            where its ``case`` tells the record layers apart.

    """

    def layout(self, msg_type: 'Enum_HandshakeType | int', *, dtls: 'bool') -> 'Optional[Type[Schema]]':
        """The structure of the extension in ``msg_type``.

        Args:
            msg_type: Handshake message carrying the extension.
            dtls: Whether the record is DTLS's.

        Returns:
            The structure, or :data:`None` where the octets are kept.

        """
        if config.MIMIC == 'wireshark':
            table = self.wireshark if not dtls or self.wireshark_dtls is None else self.wireshark_dtls
            return table.get(int(msg_type))
        if self.dtls_only and not dtls:
            return None
        return self.rfc.get(int(msg_type))

    def __init__(self, rfc: 'dict[int, Type[Schema]]', *, dtls_only: 'bool',
                 wireshark: 'dict[int, Optional[Type[Schema]]]',
                 wireshark_dtls: 'Optional[dict[int, Optional[Type[Schema]]]]') -> 'None':
        self.rfc = rfc
        self.dtls_only = dtls_only
        self.wireshark = wireshark
        self.wireshark_dtls = wireshark_dtls

    def __call__(self, pkt: 'dict[str, Any]') -> 'FieldBase':
        """Select the field of an ``extension_data``.

        Args:
            pkt: Packet data, whose ``__msg_type__`` and ``__dtls__`` keys
                :meth:`layout` reads.

        Returns:
            A field packing a value by its own type, or reading the structure
            :meth:`layout` names, or the raw octets where it names none.

        """
        value = pkt.get('data')
        if isinstance(value, Schema):
            return SchemaField(schema=type(value))
        if isinstance(value, bytes):
            return BytesField(length=len(value))
        layout = self.layout(pkt.get('__msg_type__', -1), dtls=bool(pkt.get('__dtls__')))
        if layout is None:
            return BytesField(length=pkt['__length__'])
        return SchemaField(length=pkt['__length__'], schema=layout, packet={'__data_end__': True})


def _structure(*messages: 'Enum_HandshakeType | int', schema: 'Type[Schema]', dtls_only: 'bool' = False,
               wireshark: 'dict[int, Optional[Type[Schema]]]',
               wireshark_dtls: 'Optional[dict[int, Optional[Type[Schema]]]]' = None,
               **others: 'Type[Schema]') -> '_Structures':
    """Select the structure of an ``extension_data`` by its handshake message.

    Args:
        *messages: Messages carrying ``schema``.
        schema: Structure of the extension in ``messages``.
        dtls_only: Whether only a DTLS record carries a structure, as for a
            type the IANA registry marks DTLS-only (:rfc:`9146#section-10.1`).
        wireshark: Structures with :data:`~pcapkit.utilities.config.MIMIC` at
            ``'wireshark'``, from :func:`_wireshark`.
        wireshark_dtls: Those structures in a DTLS record, where they differ.
        **others: Structures of the extension in other messages, by
            :class:`~pcapkit.const.tls.handshake_type.HandshakeType` name.

    Returns:
        The structures, an extension schema's ``__structure__`` and the selector
        of its ``data``.

    """
    table = {int(message): schema for message in messages}
    table.update({int(getattr(Enum_HandshakeType, name)): value for name, value in others.items()})
    return _Structures(table, dtls_only=dtls_only, wireshark=wireshark, wireshark_dtls=wireshark_dtls)


[docs] class Extension(EnumSchema[Enum_ExtensionType]): """Header schema for the ``extension_data`` of a TLS extension.""" __default__ = lambda: UnknownExtension if TYPE_CHECKING: #: Structures by handshake message, of a type with any. __structure__: 'ClassVar[_Structures]'
[docs] @schema_final class UnknownExtension(Extension): """Header schema for an ``extension_data`` with no structure, kept raw.""" #: The octets. data: 'bytes' = BytesField(length=lambda pkt: pkt['__length__']) if TYPE_CHECKING: def __init__(self, data: 'bytes') -> 'None': ...
[docs] @schema_final class Empty(Schema): """Header schema for ``struct {} Empty`` (:rfc:`9846#section-3.6`)."""
[docs] @schema_final class Opaque8(Schema): """Header schema for an ``opaque <..2^8-1>`` vector item.""" #: Length of :attr:`data`. length: 'int' = UInt8Field() #: The octets. data: 'bytes' = BytesField(length=lambda pkt: pkt['length']) if TYPE_CHECKING: def __init__(self, length: 'int', data: 'bytes') -> 'None': ...
[docs] @schema_final class Opaque16(Schema): """Header schema for an ``opaque <..2^16-1>`` vector item.""" #: Length of :attr:`data`. length: 'int' = UInt16Field() #: The octets. data: 'bytes' = BytesField(length=lambda pkt: pkt['length']) if TYPE_CHECKING: def __init__(self, length: 'int', data: 'bytes') -> 'None': ...
[docs] @schema_final class ServerName(Schema): """Header schema for a ``ServerName`` (:rfc:`6066#section-3`).""" #: ``NameType``. name_type: 'int' = UInt8Field() #: Length of :attr:`name`. length: 'int' = UInt16Field() #: ``HostName``. name: 'bytes' = BytesField(length=lambda pkt: pkt['length']) if TYPE_CHECKING: def __init__(self, name_type: 'int', length: 'int', name: 'bytes') -> 'None': ...
[docs] @schema_final class ServerNameList(Schema): """Header schema for a ``ServerNameList`` (:rfc:`6066#section-3`).""" #: Length of :attr:`server_name_list`. length: 'int' = UInt16Field() #: Server names. server_name_list: 'list[ServerName]' = ListField(length=lambda pkt: pkt['length'], item_type=_item(ServerName)) if TYPE_CHECKING: def __init__(self, length: 'int', server_name_list: 'list[ServerName]') -> 'None': ...
[docs] @schema_final class ServerNameExtension(Extension, code=Enum_ExtensionType.server_name): """Header schema for ``server_name`` (:rfc:`6066#section-3`).""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, schema=ServerNameList, server_hello=Empty, encrypted_extensions=Empty, wireshark=_wireshark(Empty, client_hello=ServerNameList)) #: A ``ServerNameList`` in a ``ClientHello``, empty in a ``ServerHello`` or ``EncryptedExtensions``; with #: :envvar:`PCAPKIT_MIMIC` at ``wireshark``, the list in a ``ClientHello`` and empty in each other message #: Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_SERVER_NAME`` case does. data: 'ServerNameList | Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'ServerNameList | Empty | bytes') -> 'None': ...
[docs] @schema_final class OCSPStatusRequest(Schema): """Header schema for an ``OCSPStatusRequest`` (:rfc:`6066#section-8`).""" #: Length of :attr:`responder_id_list`. responder_id_list_length: 'int' = UInt16Field() #: ``ResponderID`` values. responder_id_list: 'list[Opaque16]' = ListField(length=lambda pkt: pkt['responder_id_list_length'], item_type=_item(Opaque16)) #: Length of :attr:`request_extensions`. request_extensions_length: 'int' = UInt16Field() #: DER-encoded OCSP request ``Extensions``. request_extensions: 'bytes' = BytesField(length=lambda pkt: pkt['request_extensions_length']) if TYPE_CHECKING: def __init__(self, responder_id_list_length: 'int', responder_id_list: 'list[Opaque16]', request_extensions_length: 'int', request_extensions: 'bytes') -> 'None': ...
[docs] @schema_final class CertificateStatusRequest(Schema): """Header schema for a ``CertificateStatusRequest`` (:rfc:`6066#section-8`).""" #: ``CertificateStatusType``. status_type: 'int' = UInt8Field() #: The request, for ``ocsp``, the one type it is defined for. request: 'OCSPStatusRequest' = ConditionalField( SchemaField(length=lambda pkt: pkt['__length__'], schema=OCSPStatusRequest, packet={'__data_end__': True}), lambda pkt: pkt['status_type'] == 1, ) if TYPE_CHECKING: def __init__(self, status_type: 'int', request: 'Optional[OCSPStatusRequest]') -> 'None': ...
[docs] @schema_final class CertificateStatus(Schema): """Header schema for a ``CertificateStatus`` (:rfc:`6066#section-8`), the body of a ``Certificate``'s ``status_request`` (:rfc:`9846#section-4.5.1.1`).""" #: ``CertificateStatusType``. status_type: 'int' = UInt8Field() #: Length of :attr:`response`, for ``ocsp``, the one type it is defined for. length: 'int' = ConditionalField(NumberField(length=3, signed=False), lambda pkt: pkt['status_type'] == 1) #: DER-encoded ``OCSPResponse``, for ``ocsp``. response: 'bytes' = ConditionalField(BytesField(length=lambda pkt: pkt['length']), lambda pkt: pkt['status_type'] == 1) if TYPE_CHECKING: def __init__(self, status_type: 'int', length: 'Optional[int]', response: 'Optional[bytes]') -> 'None': ...
[docs] @schema_final class StatusRequestExtension(Extension, code=Enum_ExtensionType.status_request): """Header schema for ``status_request``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, schema=CertificateStatusRequest, server_hello=Empty, certificate_request=Empty, certificate=CertificateStatus, wireshark=_wireshark(Empty, client_hello=CertificateStatusRequest, certificate=CertificateStatus), wireshark_dtls=_wireshark(Empty, client_hello=CertificateStatusRequest)) #: A ``CertificateStatusRequest`` in a ``ClientHello``, empty in a ``ServerHello`` or #: ``CertificateRequest``, a ``CertificateStatus`` in a ``Certificate``; with :envvar:`PCAPKIT_MIMIC` at #: ``wireshark``, the request in a ``ClientHello``, the status in a TLS ``Certificate`` and empty in each #: other message Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_STATUS_REQUEST`` case does: it #: reads the status under ``is_tls13``, which a DTLS 1.3 session fails. data: 'CertificateStatusRequest | CertificateStatus | Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'CertificateStatusRequest | CertificateStatus | Empty | bytes') -> 'None': ...
[docs] @schema_final class NamedGroupList(Schema): """Header schema for a ``NamedGroupList`` (:rfc:`9846#section-4.3.7`).""" #: Length of :attr:`named_group_list`. length: 'int' = UInt16Field() #: ``NamedGroup`` values. named_group_list: 'list[int]' = ListField(length=lambda pkt: pkt['length'], item_type=UInt16Field()) if TYPE_CHECKING: def __init__(self, length: 'int', named_group_list: 'list[int]') -> 'None': ...
[docs] @schema_final class SupportedGroupsExtension(Extension, code=Enum_ExtensionType.supported_groups): """Header schema for ``supported_groups``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.encrypted_extensions, schema=NamedGroupList, wireshark=_wireshark(NamedGroupList)) #: A ``NamedGroupList`` in a ``ClientHello`` or ``EncryptedExtensions``; with :envvar:`PCAPKIT_MIMIC` at #: ``wireshark``, in each message Wireshark reads extensions in, as its #: ``SSL_HND_HELLO_EXT_SUPPORTED_GROUPS`` case does. data: 'NamedGroupList | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'NamedGroupList | bytes') -> 'None': ...
[docs] @schema_final class ECPointFormatList(Schema): """Header schema for an ``ECPointFormatList`` (:rfc:`8422#section-5.1.2`).""" #: Length of :attr:`ec_point_format_list`. length: 'int' = UInt8Field() #: ``ECPointFormat`` values. ec_point_format_list: 'list[int]' = ListField(length=lambda pkt: pkt['length'], item_type=UInt8Field()) if TYPE_CHECKING: def __init__(self, length: 'int', ec_point_format_list: 'list[int]') -> 'None': ...
[docs] @schema_final class ECPointFormatsExtension(Extension, code=Enum_ExtensionType.ec_point_formats): """Header schema for ``ec_point_formats``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.server_hello, schema=ECPointFormatList, wireshark=_wireshark(ECPointFormatList)) #: An ``ECPointFormatList`` in a ``ClientHello`` or ``ServerHello``; with :envvar:`PCAPKIT_MIMIC` at #: ``wireshark``, in each message Wireshark reads extensions in, as its #: ``SSL_HND_HELLO_EXT_EC_POINT_FORMATS`` case does. data: 'ECPointFormatList | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'ECPointFormatList | bytes') -> 'None': ...
[docs] @schema_final class SignatureSchemeList(Schema): """Header schema for a ``SignatureSchemeList`` (:rfc:`9846#section-4.3.3`).""" #: Length of :attr:`supported_signature_algorithms`. length: 'int' = UInt16Field() #: ``SignatureScheme`` values. supported_signature_algorithms: 'list[int]' = ListField(length=lambda pkt: pkt['length'], item_type=UInt16Field()) if TYPE_CHECKING: def __init__(self, length: 'int', supported_signature_algorithms: 'list[int]') -> 'None': ...
[docs] @schema_final class SignatureAlgorithmsExtension(Extension, code=Enum_ExtensionType.signature_algorithms): """Header schema for ``signature_algorithms``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.certificate_request, schema=SignatureSchemeList, wireshark=_wireshark(SignatureSchemeList)) #: A ``SignatureSchemeList`` in a ``ClientHello`` or ``CertificateRequest``; with :envvar:`PCAPKIT_MIMIC` at #: ``wireshark``, in each message Wireshark reads extensions in, as its #: ``SSL_HND_HELLO_EXT_SIGNATURE_ALGORITHMS`` case does. data: 'SignatureSchemeList | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'SignatureSchemeList | bytes') -> 'None': ...
[docs] @schema_final class ProtocolNameList(Schema): """Header schema for a ``ProtocolNameList`` (:rfc:`7301#section-3.1`).""" #: Length of :attr:`protocol_name_list`. length: 'int' = UInt16Field() #: ``ProtocolName`` values. protocol_name_list: 'list[Opaque8]' = ListField(length=lambda pkt: pkt['length'], item_type=_item(Opaque8)) if TYPE_CHECKING: def __init__(self, length: 'int', protocol_name_list: 'list[Opaque8]') -> 'None': ...
[docs] @schema_final class ALPNExtension(Extension, code=Enum_ExtensionType.application_layer_protocol_negotiation): """Header schema for ``application_layer_protocol_negotiation``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.server_hello, Enum_HandshakeType.encrypted_extensions, schema=ProtocolNameList, wireshark=_wireshark(ProtocolNameList)) #: A ``ProtocolNameList`` in a ``ClientHello``, ``ServerHello`` or ``EncryptedExtensions``; with #: :envvar:`PCAPKIT_MIMIC` at ``wireshark``, in each message Wireshark reads extensions in, as its #: ``SSL_HND_HELLO_EXT_ALPN`` case does. data: 'ProtocolNameList | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'ProtocolNameList | bytes') -> 'None': ...
[docs] @schema_final class SignedCertificateTimestampList(Schema): """Header schema for a ``SignedCertificateTimestampList`` (:rfc:`6962#section-3.3`).""" #: Length of :attr:`sct_list`. length: 'int' = UInt16Field() #: ``SerializedSCT`` values. sct_list: 'list[Opaque16]' = ListField(length=lambda pkt: pkt['length'], item_type=_item(Opaque16)) if TYPE_CHECKING: def __init__(self, length: 'int', sct_list: 'list[Opaque16]') -> 'None': ...
[docs] @schema_final class SignedCertificateTimestampExtension(Extension, code=Enum_ExtensionType.signed_certificate_timestamp): """Header schema for ``signed_certificate_timestamp``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.certificate_request, schema=Empty, server_hello=SignedCertificateTimestampList, certificate=SignedCertificateTimestampList, wireshark=_wireshark(Empty, server_hello=SignedCertificateTimestampList, encrypted_extensions=SignedCertificateTimestampList, certificate=SignedCertificateTimestampList)) #: Empty in a ``ClientHello`` or ``CertificateRequest``, a ``SignedCertificateTimestampList`` in a #: ``ServerHello`` or ``Certificate``; with :envvar:`PCAPKIT_MIMIC` at ``wireshark``, the list in a #: ``ServerHello``, ``EncryptedExtensions`` or ``Certificate`` and empty in each other message Wireshark #: reads extensions in, as its ``SSL_HND_HELLO_EXT_SIGNED_CERTIFICATE_TIMESTAMP`` case does. data: 'SignedCertificateTimestampList | Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'SignedCertificateTimestampList | Empty | bytes') -> 'None': ...
[docs] @schema_final class Padding(Schema): """Header schema for the ``padding`` of :rfc:`7685#section-3`.""" #: The padding octets, as captured. padding: 'bytes' = BytesField(length=lambda pkt: pkt['__length__']) if TYPE_CHECKING: def __init__(self, padding: 'bytes') -> 'None': ...
[docs] @schema_final class PaddingExtension(Extension, code=Enum_ExtensionType.padding): """Header schema for ``padding``.""" #: Structures by handshake message. __structure__ = _structure(Enum_HandshakeType.client_hello, schema=Padding, wireshark=_wireshark(Padding)) #: The padding in a ``ClientHello``; with :envvar:`PCAPKIT_MIMIC` at ``wireshark``, in each message #: Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_PADDING`` case does. data: 'Padding | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'Padding | bytes') -> 'None': ...
[docs] @schema_final class ExtendedMainSecretExtension(Extension, code=Enum_ExtensionType.extended_main_secret): """Header schema for ``extended_main_secret`` (:rfc:`7627#section-5.1`).""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.server_hello, schema=Empty, wireshark=_wireshark(Empty)) #: Empty in a ``ClientHello`` or ``ServerHello``; with :envvar:`PCAPKIT_MIMIC` at ``wireshark``, in each #: message Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_EXTENDED_MASTER_SECRET`` case does. data: 'Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'Empty | bytes') -> 'None': ...
[docs] @schema_final class CertificateCompressionAlgorithms(Schema): """Header schema for a ``CertificateCompressionAlgorithms`` (:rfc:`8879#section-3`).""" #: Length of :attr:`algorithms`. length: 'int' = UInt8Field() #: ``CertificateCompressionAlgorithm`` values. algorithms: 'list[int]' = ListField(length=lambda pkt: pkt['length'], item_type=UInt16Field()) if TYPE_CHECKING: def __init__(self, length: 'int', algorithms: 'list[int]') -> 'None': ...
[docs] @schema_final class CompressCertificateExtension(Extension, code=Enum_ExtensionType.compress_certificate): """Header schema for ``compress_certificate``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.certificate_request, schema=CertificateCompressionAlgorithms, wireshark=_wireshark(Empty, client_hello=CertificateCompressionAlgorithms, certificate_request=CertificateCompressionAlgorithms)) #: A ``CertificateCompressionAlgorithms`` in a ``ClientHello`` or ``CertificateRequest``; with #: :envvar:`PCAPKIT_MIMIC` at ``wireshark``, the list there too and empty in each other message #: Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_COMPRESS_CERTIFICATE`` case does. data: 'CertificateCompressionAlgorithms | Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'CertificateCompressionAlgorithms | Empty | bytes') -> 'None': ...
[docs] @schema_final class RecordSizeLimit(Schema): """Header schema for a ``RecordSizeLimit`` (:rfc:`8449#section-4`).""" #: Largest record, in octets. record_size_limit: 'int' = UInt16Field() if TYPE_CHECKING: def __init__(self, record_size_limit: 'int') -> 'None': ...
[docs] @schema_final class RecordSizeLimitExtension(Extension, code=Enum_ExtensionType.record_size_limit): """Header schema for ``record_size_limit``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.server_hello, Enum_HandshakeType.encrypted_extensions, schema=RecordSizeLimit, wireshark=_wireshark(RecordSizeLimit)) #: A ``RecordSizeLimit`` in a ``ClientHello``, ``ServerHello`` or ``EncryptedExtensions``; with #: :envvar:`PCAPKIT_MIMIC` at ``wireshark``, in each message Wireshark reads extensions in, as its #: ``SSL_HND_HELLO_EXT_RECORD_SIZE_LIMIT`` case does. data: 'RecordSizeLimit | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'RecordSizeLimit | bytes') -> 'None': ...
[docs] @schema_final class SessionTicket(Schema): """Header schema for a ``SessionTicket`` (:rfc:`5077#section-3.2`), with no length of its own.""" #: The ticket. ticket: 'bytes' = BytesField(length=lambda pkt: pkt['__length__']) if TYPE_CHECKING: def __init__(self, ticket: 'bytes') -> 'None': ...
[docs] @schema_final class SessionTicketExtension(Extension, code=Enum_ExtensionType.session_ticket): """Header schema for ``session_ticket``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.server_hello, schema=SessionTicket, wireshark=_wireshark(SessionTicket)) #: The ticket in a ``ClientHello`` or ``ServerHello``; with :envvar:`PCAPKIT_MIMIC` at ``wireshark``, in #: each message Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_SESSION_TICKET_TLS`` case does. data: 'SessionTicket | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'SessionTicket | bytes') -> 'None': ...
[docs] @schema_final class PskIdentity(Schema): """Header schema for a ``PskIdentity`` (:rfc:`9846#section-4.3.11`).""" #: Length of :attr:`identity`. length: 'int' = UInt16Field() #: The identity. identity: 'bytes' = BytesField(length=lambda pkt: pkt['length']) #: Obfuscated ticket age. obfuscated_ticket_age: 'int' = UInt32Field() if TYPE_CHECKING: def __init__(self, length: 'int', identity: 'bytes', obfuscated_ticket_age: 'int') -> 'None': ...
[docs] @schema_final class OfferedPsks(Schema): """Header schema for an ``OfferedPsks`` (:rfc:`9846#section-4.3.11`).""" #: Length of :attr:`identities`. identities_length: 'int' = UInt16Field() #: The identities. identities: 'list[PskIdentity]' = ListField(length=lambda pkt: pkt['identities_length'], item_type=_item(PskIdentity)) #: Length of :attr:`binders`. binders_length: 'int' = UInt16Field() #: ``PskBinderEntry`` values. binders: 'list[Opaque8]' = ListField(length=lambda pkt: pkt['binders_length'], item_type=_item(Opaque8)) if TYPE_CHECKING: def __init__(self, identities_length: 'int', identities: 'list[PskIdentity]', binders_length: 'int', binders: 'list[Opaque8]') -> 'None': ...
[docs] @schema_final class PreSharedKeyServerHello(Schema): """Header schema for a ``ServerHello``'s ``pre_shared_key`` (:rfc:`9846#section-4.3.11`).""" #: Index of the identity selected. selected_identity: 'int' = UInt16Field() if TYPE_CHECKING: def __init__(self, selected_identity: 'int') -> 'None': ...
[docs] @schema_final class PreSharedKeyExtension(Extension, code=Enum_ExtensionType.pre_shared_key): """Header schema for ``pre_shared_key``, a ``PreSharedKeyExtension``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, schema=OfferedPsks, server_hello=PreSharedKeyServerHello, wireshark=_wireshark(Empty, client_hello=OfferedPsks, server_hello=PreSharedKeyServerHello)) #: An ``OfferedPsks`` in a ``ClientHello``, the selection in a ``ServerHello``; with :envvar:`PCAPKIT_MIMIC` #: at ``wireshark``, these and empty in each other message Wireshark reads extensions in, as its #: ``SSL_HND_HELLO_EXT_PRE_SHARED_KEY`` case does. data: 'OfferedPsks | PreSharedKeyServerHello | Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'OfferedPsks | PreSharedKeyServerHello | Empty | bytes') -> 'None': ...
[docs] @schema_final class EarlyDataNewSessionTicket(Schema): """Header schema for a ``NewSessionTicket``'s ``early_data`` (:rfc:`9846#section-4.3.10`).""" #: Largest amount of 0-RTT data, in octets, the client may send under the ticket. max_early_data_size: 'int' = UInt32Field() if TYPE_CHECKING: def __init__(self, max_early_data_size: 'int') -> 'None': ...
[docs] @schema_final class EarlyDataExtension(Extension, code=Enum_ExtensionType.early_data): """Header schema for ``early_data``, an ``EarlyDataIndication`` (:rfc:`9846#section-4.3.10`).""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.encrypted_extensions, schema=Empty, new_session_ticket=EarlyDataNewSessionTicket, wireshark=_wireshark(Empty, new_session_ticket=EarlyDataNewSessionTicket)) #: Empty in a ``ClientHello`` or ``EncryptedExtensions``, the ``max_early_data_size`` in a #: ``NewSessionTicket``; with :envvar:`PCAPKIT_MIMIC` at ``wireshark``, the size in a ``NewSessionTicket`` #: and empty in each other message Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_EARLY_DATA`` #: case does. data: 'EarlyDataNewSessionTicket | Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'EarlyDataNewSessionTicket | Empty | bytes') -> 'None': ...
[docs] @schema_final class SupportedVersionsClientHello(Schema): """Header schema for a ``ClientHello``'s ``supported_versions`` (:rfc:`9846#section-4.3.1`).""" #: Length of :attr:`versions`. length: 'int' = UInt8Field() #: ``ProtocolVersion`` values. versions: 'list[int]' = ListField(length=lambda pkt: pkt['length'], item_type=UInt16Field()) if TYPE_CHECKING: def __init__(self, length: 'int', versions: 'list[int]') -> 'None': ...
[docs] @schema_final class SupportedVersionsServerHello(Schema): """Header schema for a ``ServerHello``'s ``supported_versions`` (:rfc:`9846#section-4.3.1`).""" #: ``ProtocolVersion`` selected. selected_version: 'int' = UInt16Field() if TYPE_CHECKING: def __init__(self, selected_version: 'int') -> 'None': ...
[docs] @schema_final class SupportedVersionsExtension(Extension, code=Enum_ExtensionType.supported_versions): """Header schema for ``supported_versions``, a ``SupportedVersions``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, schema=SupportedVersionsClientHello, server_hello=SupportedVersionsServerHello, hello_retry_request=SupportedVersionsServerHello, wireshark=_wireshark(Empty, client_hello=SupportedVersionsClientHello, server_hello=SupportedVersionsServerHello, hello_retry_request=SupportedVersionsServerHello)) #: The versions in a ``ClientHello``, the selection in a ``ServerHello`` or ``HelloRetryRequest``; with #: :envvar:`PCAPKIT_MIMIC` at ``wireshark``, these and empty in each other message Wireshark reads #: extensions in, as its ``SSL_HND_HELLO_EXT_SUPPORTED_VERSIONS`` case does. data: 'SupportedVersionsClientHello | SupportedVersionsServerHello | Empty | bytes' = SwitchField( selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'SupportedVersionsClientHello | SupportedVersionsServerHello | Empty | bytes') -> 'None': ... # pylint: disable=line-too-long
[docs] @schema_final class CookieExtension(Extension, code=Enum_ExtensionType.cookie): """Header schema for ``cookie``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.hello_retry_request, schema=Cookie, wireshark=_wireshark(Cookie)) #: A ``Cookie`` in a ``ClientHello`` or ``HelloRetryRequest``; with :envvar:`PCAPKIT_MIMIC` at #: ``wireshark``, in each message Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_COOKIE`` case #: does. data: 'Cookie | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'Cookie | bytes') -> 'None': ...
[docs] @schema_final class PskKeyExchangeModes(Schema): """Header schema for a ``PskKeyExchangeModes`` (:rfc:`9846#section-4.3.9`).""" #: Length of :attr:`ke_modes`. length: 'int' = UInt8Field() #: ``PskKeyExchangeMode`` values. ke_modes: 'list[int]' = ListField(length=lambda pkt: pkt['length'], item_type=UInt8Field()) if TYPE_CHECKING: def __init__(self, length: 'int', ke_modes: 'list[int]') -> 'None': ...
[docs] @schema_final class PskKeyExchangeModesExtension(Extension, code=Enum_ExtensionType.psk_key_exchange_modes): """Header schema for ``psk_key_exchange_modes``.""" #: Structures by handshake message. __structure__ = _structure(Enum_HandshakeType.client_hello, schema=PskKeyExchangeModes, wireshark=_wireshark(PskKeyExchangeModes)) #: A ``PskKeyExchangeModes`` in a ``ClientHello``; with :envvar:`PCAPKIT_MIMIC` at ``wireshark``, in each #: message Wireshark reads extensions in, as its ``SSL_HND_HELLO_EXT_PSK_KEY_EXCHANGE_MODES`` case does. data: 'PskKeyExchangeModes | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'PskKeyExchangeModes | bytes') -> 'None': ...
[docs] @schema_final class PostHandshakeAuthExtension(Extension, code=Enum_ExtensionType.post_handshake_auth): """Header schema for ``post_handshake_auth`` (:rfc:`9846#section-4.3.6`).""" #: Structures by handshake message. __structure__ = _structure(Enum_HandshakeType.client_hello, schema=Empty, wireshark=_wireshark(Empty)) #: Empty in a ``ClientHello``; with :envvar:`PCAPKIT_MIMIC` at ``wireshark``, in each message Wireshark #: reads extensions in, as its ``SSL_HND_HELLO_EXT_POST_HANDSHAKE_AUTH`` case does. data: 'Empty | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'Empty | bytes') -> 'None': ...
[docs] @schema_final class KeyShareEntry(Schema): """Header schema for a ``KeyShareEntry`` (:rfc:`9846#section-4.3.8`).""" #: ``NamedGroup``. group: 'int' = UInt16Field() #: Length of :attr:`key_exchange`. length: 'int' = UInt16Field() #: Key exchange information. key_exchange: 'bytes' = BytesField(length=lambda pkt: pkt['length']) if TYPE_CHECKING: def __init__(self, group: 'int', length: 'int', key_exchange: 'bytes') -> 'None': ...
[docs] @schema_final class KeyShareClientHello(Schema): """Header schema for a ``KeyShareClientHello`` (:rfc:`9846#section-4.3.8`).""" #: Length of :attr:`client_shares`. length: 'int' = UInt16Field() #: Key shares offered. client_shares: 'list[KeyShareEntry]' = ListField(length=lambda pkt: pkt['length'], item_type=_item(KeyShareEntry)) if TYPE_CHECKING: def __init__(self, length: 'int', client_shares: 'list[KeyShareEntry]') -> 'None': ...
[docs] @schema_final class KeyShareHelloRetryRequest(Schema): """Header schema for a ``KeyShareHelloRetryRequest`` (:rfc:`9846#section-4.3.8`).""" #: ``NamedGroup`` selected. selected_group: 'int' = UInt16Field() if TYPE_CHECKING: def __init__(self, selected_group: 'int') -> 'None': ...
[docs] @schema_final class KeyShareServerHello(Schema): """Header schema for a ``KeyShareServerHello`` (:rfc:`9846#section-4.3.8`).""" #: Key share selected. server_share: 'KeyShareEntry' = SchemaField(length=lambda pkt: pkt['__length__'], schema=KeyShareEntry, packet={'__data_end__': True}) if TYPE_CHECKING: def __init__(self, server_share: 'KeyShareEntry') -> 'None': ...
[docs] @schema_final class KeyShareExtension(Extension, code=Enum_ExtensionType.key_share): """Header schema for ``key_share``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, schema=KeyShareClientHello, hello_retry_request=KeyShareHelloRetryRequest, server_hello=KeyShareServerHello, wireshark=_wireshark(Empty, client_hello=KeyShareClientHello, hello_retry_request=KeyShareHelloRetryRequest, server_hello=KeyShareServerHello)) #: The structure of a ``ClientHello``, ``HelloRetryRequest`` or ``ServerHello``; with #: :envvar:`PCAPKIT_MIMIC` at ``wireshark``, these and empty in each other message Wireshark reads #: extensions in, as its ``SSL_HND_HELLO_EXT_KEY_SHARE`` case does. data: 'KeyShareClientHello | KeyShareHelloRetryRequest | KeyShareServerHello | Empty | bytes' = SwitchField( selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'KeyShareClientHello | KeyShareHelloRetryRequest | KeyShareServerHello | Empty | bytes') -> 'None': ... # pylint: disable=line-too-long
[docs] @schema_final class ConnectionId(Schema): """Header schema for a ``ConnectionId`` (:rfc:`9146#section-3`).""" #: Length of :attr:`cid`. length: 'int' = UInt8Field() #: The connection ID. cid: 'bytes' = BytesField(length=lambda pkt: pkt['length']) if TYPE_CHECKING: def __init__(self, length: 'int', cid: 'bytes') -> 'None': ...
[docs] @schema_final class ConnectionIdExtension(Extension, code=Enum_ExtensionType.connection_id): """Header schema for ``connection_id``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.server_hello, schema=ConnectionId, dtls_only=True, wireshark=_wireshark(None, client_hello=ConnectionId, server_hello=ConnectionId)) #: A ``ConnectionId`` in a DTLS ``ClientHello`` or ``ServerHello``; with :envvar:`PCAPKIT_MIMIC` at #: ``wireshark``, in a TLS one too, as its ``SSL_HND_HELLO_EXT_CONNECTION_ID`` case does. That case reads the #: length octet before it looks at the message, past the end of an empty body, so the octets stay raw in #: the others. data: 'ConnectionId | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'ConnectionId | bytes') -> 'None': ...
[docs] @schema_final class HpkeSymmetricCipherSuite(Schema): """Header schema for an ``HpkeSymmetricCipherSuite`` (:rfc:`9849#section-4`).""" #: ``HpkeKdfId``. kdf_id: 'Enum_HpkeKdfId' = EnumField(length=2, namespace=Enum_HpkeKdfId) #: ``HpkeAeadId``. aead_id: 'Enum_HpkeAeadId' = EnumField(length=2, namespace=Enum_HpkeAeadId) if TYPE_CHECKING: def __init__(self, kdf_id: 'Enum_HpkeKdfId | int', aead_id: 'Enum_HpkeAeadId | int') -> 'None': ...
def _ech_outer(pkt: 'dict[str, Any]') -> 'bool': """Whether an ``ECHClientHello`` is of the ``outer`` type, 0.""" return pkt['type'] == 0
[docs] @schema_final class ECHClientHello(Schema): """Header schema for an ``ECHClientHello`` (:rfc:`9849#section-5`).""" #: Client hello type, ``ECHClientHelloType``, ``outer`` (0) or ``inner`` (1). type: 'int' = UInt8Field() #: Cipher suite, for ``outer``. cipher_suite: 'HpkeSymmetricCipherSuite' = ConditionalField( SchemaField(length=4, schema=HpkeSymmetricCipherSuite, packet={'__data_end__': True}), _ech_outer) #: ``config_id``, for ``outer``. config_id: 'int' = ConditionalField(UInt8Field(), _ech_outer) #: Length of :attr:`enc`, for ``outer``. enc_length: 'int' = ConditionalField(UInt16Field(), _ech_outer) #: Encapsulated key, for ``outer``. enc: 'bytes' = ConditionalField(BytesField(length=lambda pkt: pkt['enc_length']), _ech_outer) #: Length of :attr:`payload`, for ``outer``. payload_length: 'int' = ConditionalField(UInt16Field(), _ech_outer) #: Encrypted payload, for ``outer``. payload: 'bytes' = ConditionalField(BytesField(length=lambda pkt: pkt['payload_length']), _ech_outer) if TYPE_CHECKING: def __init__(self, type: 'int', cipher_suite: 'Optional[HpkeSymmetricCipherSuite]' = None, config_id: 'Optional[int]' = None, enc_length: 'Optional[int]' = None, enc: 'Optional[bytes]' = None, payload_length: 'Optional[int]' = None, payload: 'Optional[bytes]' = None) -> 'None': ...
[docs] @schema_final class ECHHelloRetryRequest(Schema): """Header schema for an ``ECHHelloRetryRequest`` (:rfc:`9849#section-5`).""" #: Acceptance confirmation. confirmation: 'bytes' = BytesField(length=_ECH_CONFIRMATION_LENGTH) if TYPE_CHECKING: def __init__(self, confirmation: 'bytes') -> 'None': ...
[docs] @schema_final class ECHConfigExtension(Schema): """Header schema for an ``ECHConfigExtension`` (:rfc:`9849#section-4`).""" #: ``ECHConfigExtensionType``. type: 'int' = UInt16Field() #: Length of :attr:`data`. length: 'int' = UInt16Field() #: Extension data. data: 'bytes' = BytesField(length=lambda pkt: pkt['length']) if TYPE_CHECKING: def __init__(self, type: 'int', length: 'int', data: 'bytes') -> 'None': ...
[docs] @schema_final class ECHConfigContents(Schema): """Header schema for an ``ECHConfigContents`` (:rfc:`9849#section-4`), its ``HpkeKeyConfig`` inline, since that has no length of its own.""" #: ``config_id`` of the ``HpkeKeyConfig``. config_id: 'int' = UInt8Field() #: ``HpkeKemId`` of the ``HpkeKeyConfig``. kem_id: 'Enum_HpkeKemId' = EnumField(length=2, namespace=Enum_HpkeKemId) #: Length of :attr:`public_key`. public_key_length: 'int' = UInt16Field() #: ``HpkePublicKey`` of the ``HpkeKeyConfig``. public_key: 'bytes' = BytesField(length=lambda pkt: pkt['public_key_length']) #: Length of :attr:`cipher_suites`. cipher_suites_length: 'int' = UInt16Field() #: Cipher suites of the ``HpkeKeyConfig``. cipher_suites: 'list[HpkeSymmetricCipherSuite]' = ListField(length=lambda pkt: pkt['cipher_suites_length'], item_type=_item(HpkeSymmetricCipherSuite)) #: Longest name the client may pad its inner name to. maximum_name_length: 'int' = UInt8Field() #: Length of :attr:`public_name`. public_name_length: 'int' = UInt8Field() #: Public name. public_name: 'bytes' = BytesField(length=lambda pkt: pkt['public_name_length']) #: Length of :attr:`extensions`. extensions_length: 'int' = UInt16Field() #: Configuration extensions. extensions: 'list[ECHConfigExtension]' = ListField(length=lambda pkt: pkt['extensions_length'], item_type=_item(ECHConfigExtension)) if TYPE_CHECKING: def __init__(self, config_id: 'int', kem_id: 'Enum_HpkeKemId | int', public_key_length: 'int', public_key: 'bytes', cipher_suites_length: 'int', cipher_suites: 'list[HpkeSymmetricCipherSuite]', maximum_name_length: 'int', public_name_length: 'int', public_name: 'bytes', extensions_length: 'int', extensions: 'list[ECHConfigExtension]') -> 'None': ...
def _ech_config_contents(pkt: 'dict[str, Any]') -> 'FieldBase': """Select an ``ECHConfig``'s ``contents``: the structure of version ``0xFE0D``, or the octets. Args: pkt: Packet data. Returns: A field of :class:`ECHConfigContents` for version ``0xFE0D``, unless it packs octets given as they are, and of the octets otherwise. """ if pkt['version'] == _ECH_CONFIG_VERSION and not isinstance(pkt.get('contents'), bytes): return SchemaField(length=pkt['length'], schema=ECHConfigContents, packet={'__data_end__': True}) return BytesField(length=pkt['length'])
[docs] @schema_final class ECHConfig(Schema): """Header schema for an ``ECHConfig`` (:rfc:`9849#section-4`).""" #: Version. version: 'int' = UInt16Field() #: Length of :attr:`contents`. length: 'int' = UInt16Field() #: The contents of version ``0xFE0D``; the raw octets of any other. contents: 'ECHConfigContents | bytes' = SwitchField(selector=lambda pkt: _ech_config_contents(pkt)) if TYPE_CHECKING: def __init__(self, version: 'int', length: 'int', contents: 'ECHConfigContents | bytes') -> 'None': ...
[docs] @schema_final class ECHEncryptedExtensions(Schema): """Header schema for an ``ECHEncryptedExtensions`` (:rfc:`9849#section-5`).""" #: Length of :attr:`retry_configs`. length: 'int' = UInt16Field() #: Retry configurations, an ``ECHConfigList``. retry_configs: 'list[ECHConfig]' = ListField(length=lambda pkt: pkt['length'], item_type=_item(ECHConfig)) if TYPE_CHECKING: def __init__(self, length: 'int', retry_configs: 'list[ECHConfig]') -> 'None': ...
[docs] @schema_final class ECHExtension(Extension, code=Enum_ExtensionType.encrypted_client_hello): """Header schema for ``encrypted_client_hello``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, schema=ECHClientHello, hello_retry_request=ECHHelloRetryRequest, encrypted_extensions=ECHEncryptedExtensions, wireshark=_wireshark(Empty, client_hello=ECHClientHello, hello_retry_request=ECHHelloRetryRequest, encrypted_extensions=ECHEncryptedExtensions)) #: An ``ECHClientHello``, ``ECHHelloRetryRequest`` or ``ECHEncryptedExtensions``; with #: :envvar:`PCAPKIT_MIMIC` at ``wireshark``, these and empty in each other message Wireshark reads #: extensions in, as its ``SSL_HND_HELLO_EXT_ENCRYPTED_CLIENT_HELLO`` case does. data: 'ECHClientHello | ECHHelloRetryRequest | ECHEncryptedExtensions | Empty | bytes' = SwitchField( selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'ECHClientHello | ECHHelloRetryRequest | ECHEncryptedExtensions | Empty | bytes') -> 'None': ... # pylint: disable=line-too-long
[docs] @schema_final class RenegotiationInfo(Schema): """Header schema for a ``RenegotiationInfo`` (:rfc:`5746#section-3.2`).""" #: Length of :attr:`renegotiated_connection`. length: 'int' = UInt8Field() #: ``verify_data`` of the previous handshake. renegotiated_connection: 'bytes' = BytesField(length=lambda pkt: pkt['length']) if TYPE_CHECKING: def __init__(self, length: 'int', renegotiated_connection: 'bytes') -> 'None': ...
[docs] @schema_final class RenegotiationInfoExtension(Extension, code=Enum_ExtensionType.renegotiation_info): """Header schema for ``renegotiation_info``.""" #: Structures by handshake message. __structure__ = _structure( Enum_HandshakeType.client_hello, Enum_HandshakeType.server_hello, schema=RenegotiationInfo, wireshark=_wireshark(RenegotiationInfo)) #: A ``RenegotiationInfo`` in a ``ClientHello`` or ``ServerHello``; with :envvar:`PCAPKIT_MIMIC` at #: ``wireshark``, in each message Wireshark reads extensions in, as its #: ``SSL_HND_HELLO_EXT_RENEGOTIATION_INFO`` case does. data: 'RenegotiationInfo | bytes' = SwitchField(selector=__structure__) if TYPE_CHECKING: def __init__(self, data: 'RenegotiationInfo | bytes') -> 'None': ...