Messages Module

class mtf.network_port.tls.helpers.messages.ClientHello

Represents a TLS ClientHello message, which is sent by the client to initiate a TLS handshake with the server.

Attributes:

protocol_version (bytes): The version of the TLS protocol proposed by the client.

unix_time (bytes): The current time in UNIX timestamp format (4 bytes).

random (bytes): A random value generated by the client (28 bytes).

session_id_length (int): The length of the session ID.

session_id (bytes): The current session ID (if a session resumption attempt is being made).

compression_length (int): The length of the compression methods list.

cipher_suite_length (int): The length of the cipher_suites list.

cipher_suites (list): The list of supported cipher suites by the client.

compressions (list): The list of supported compression methods by the client.

cookie (bytes): A stateless cookie (used in DTLS) for verifying the client identity.

cookie_length (int): The length of the cookie.

protocol_version: bytes
unix_time: bytes
random: bytes
session_id_length: int
session_id: bytes
compression_length: int
cipher_suite_length: int
cipher_suites: list
compressions: list
extensions: Any | None
cookie: bytes | None
cookie_length: int | None
__init__(protocol_version: bytes, unix_time: bytes, random: bytes, session_id_length: int, session_id: bytes, compression_length: int, cipher_suite_length: int, cipher_suites: list, compressions: list, extensions: Any | None = None, cookie: bytes | None = None, cookie_length: int | None = None) None
class mtf.network_port.tls.helpers.messages.ServerHello

Represents a TLS ServerHello message, which is the server’s response to the client’s ClientHello in a TLS handshake.

Attributes:

protocol_version (bytes): The version of the TLS protocol selected by the server.

unix_time (bytes): The current time in UNIX timestamp format (4 bytes).

random (bytes): A random value generated by the server (28 bytes).

session_id_length (int): The length of the session ID.

session_id (bytes): The chosen or resumed session ID.

selected_cipher_suite (bytes): The cipher suite selected by the server.

selected_compression_method (bytes): The compression method selected by the server.

auto_set_hello_retry_mode_in_key_share (bool): Indicates if HelloRetryRequest mode should be set automatically in the key share (applicable in TLS 1.3).

protocol_version: bytes
unix_time: bytes
random: bytes
session_id_length: int
session_id: bytes
selected_cipher_suite: bytes
selected_compression_method: bytes
auto_set_hello_retry_mode_in_key_share: bool | None
extensions: Any | None
__init__(protocol_version: bytes, unix_time: bytes, random: bytes, session_id_length: int, session_id: bytes, selected_cipher_suite: bytes, selected_compression_method: bytes, auto_set_hello_retry_mode_in_key_share: bool | None = None, extensions: Any | None = None) None
class mtf.network_port.tls.helpers.messages.ServerHelloDone

Represents the ‘ServerHelloDone’ message in the TLS handshake process.

Attributes:
length (bytes): The length field of the ‘ServerHelloDone’ message,

typically an empty byte sequence since this message contains no payload.

length: bytes
__init__(length: bytes) None
class mtf.network_port.tls.helpers.messages.HelloVerifyRequest

Represents a DTLS HelloVerifyRequest message, which is used to prevent Denial-of-Service attacks by verifying that the client can receive packets at the claimed source address.

Attributes:

protocol_version (bytes): The DTLS protocol version.

cookie_length (bytes): The length of the cookie.

cookie (bytes): The stateless cookie the client must echo in its next ClientHello.

protocol_version: bytes
cookie_length: bytes
cookie: bytes
__init__(protocol_version: bytes, cookie_length: bytes, cookie: bytes) None
class mtf.network_port.tls.helpers.messages.PskClientKeyExchange

Represents the PSK (Pre-Shared Key) ClientKeyExchange message, which sends the identity of the pre-shared key the client wishes to use.

Attributes:

identity (int): The pre-shared key identity (an identifier for a known PSK).

identity_length (bytes): The length of the identity field.

identity: int
identity_length: bytes
__init__(identity: int, identity_length: bytes) None
class mtf.network_port.tls.helpers.messages.PskServerKeyExchange

Represents the PSK (Pre-Shared Key) ServerKeyExchange message, which sends an optional identity hint to the client.

Attributes:

identity_hint (int): A hint for which pre-shared key the client should use.

identity_hint_length (bytes): The length of the identity hint field.

identity_hint: int
identity_hint_length: bytes
__init__(identity_hint: int, identity_hint_length: bytes) None
class mtf.network_port.tls.helpers.messages.Alert

Represents a TLS Alert message, which indicates that a particular event or error has occurred during a TLS session.

Attributes:

level (bytes): The alert level (warning(1) or fatal(2)).

description (bytes): A single byte describing the alert type (e.g. close_notify, unexpected_message, etc.).

level: bytes
description: bytes
__init__(level: bytes, description: bytes) None
class mtf.network_port.tls.helpers.messages.ChangeCipherSpec

Represents a TLS ChangeCipherSpec message, which notifies the receiving party that subsequent records will be protected under the newly negotiated CipherSpec and keys.

Attributes:

ccs_protocol_type (bytes): Indicates the type (usually a single byte with the value 1 to indicate a ChangeCipherSpec message).

ccs_protocol_type: bytes
__init__(ccs_protocol_type: bytes) None
class mtf.network_port.tls.helpers.messages.Finished

Represents a TLS Finished message, which is sent to indicate that the handshake is complete. It contains a cryptographic hash of the handshake messages sent or received so far.

Attributes:

verify_data (bytes): A value computed from the handshake messages, used to verify that both parties have the same handshake state.

verify_data: bytes
__init__(verify_data: bytes) None
class mtf.network_port.tls.helpers.messages.SessionTicket

Represents a TLS Session Ticket.

Attributes:

length (int): The length of the session ticket.

length: int
__init__(length: int) None
class mtf.network_port.tls.helpers.messages.EncryptedExtensions

Represents the EncryptedExtensions message in TLS 1.3.

Attributes:

extensions_length (bytes): The length of the encrypted extensions.

extensions_length: bytes
__init__(extensions_length: bytes) None
class mtf.network_port.tls.helpers.messages.Certificate

Represents a TLS Certificate.

Attributes:

subject_name (str): The subject name of the certificate.

issuer_name (str): The issuer name of the certificate.

serial_number (str): The serial number of the certificate in hexadecimal format.

not_valid_before (str): The start date of certificate validity in ISO format.

not_valid_after (str): The expiration date of certificate validity in ISO format.

data (str): The certificate data in hexadecimal format.

subject_name: str
issuer_name: str
serial_number: str
not_valid_before: str
not_valid_after: str
data: str
__init__(subject_name: str, issuer_name: str, serial_number: str, not_valid_before: str, not_valid_after: str, data: str) None
class mtf.network_port.tls.helpers.messages.CertificateMessage

Represents a TLS Certificate Message.

Attributes:

certificates_length (int): The total length of the certificate chain.

certificates (Certificate): The parsed certificate information.

certificates_length: int
certificates: Certificate
__init__(certificates_length: int, certificates: Certificate) None
class mtf.network_port.tls.helpers.messages.CertificateRequest

Represents a Certificate Request message in TLS.

Attributes:

certificate_request_length (int): The length of the certificate request.

certificate_request_length: int
__init__(certificate_request_length: int) None
class mtf.network_port.tls.helpers.messages.CertificateVerify

Represents a CertificateVerify message in TLS.

Attributes:

signature_algorithm (str): The algorithm used for signing the certificate.

signature_length (int): The length of the signature.

signature (bytes): The actual signature data.

signature_algorithm: str
signature_length: int
signature: bytes
__init__(signature_algorithm: str, signature_length: int, signature: bytes) None