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

Represents a TLS HelloRequest message, which is sent by the server to notify the client that it should begin a new handshake (i.e., renegotiate the connection). It’s simply an invitation to restart the negotiation process.

Attributes:
length (bytes): The length field of the ‘HelloRequest’ 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.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.ClientKeyExchange

Represents the client key exchange message in a TLS handshake.

This message is used during the TLS handshake process to securely exchange cryptographic information between the client and the server, typically including a public key used for key agreement.

Attributes:

public_key_length (int): The length of the public key in bytes.

public_key (bytes): The public key sent by the client, typically used for securely establishing a shared secret.

public_key_length: int
public_key: bytes
__init__(public_key_length: int, public_key: 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.ServerKeyExchange

Represents the server key exchange message in a TLS handshake.

This message is used during the TLS handshake to securely exchange cryptographic information from the server to the client. It includes the server’s public key, signature, and the algorithm used for the signature to ensure the integrity and authenticity of the server’s cryptographic data.

Attributes:

signature_and_hash_algorithm (bytes): The algorithm used for signing the server’s key exchange message.

signature_length (int): The length of the signature in bytes.

signature (bytes): The signature created by the server to verify the authenticity of the server’s public key and other parameters.

public_key_length (int): The length of the server’s public key in bytes.

public_key (bytes): The server’s public key used for securely establishing a shared secret during the handshake.

signature_and_hash_algorithm: bytes
signature_length: int
signature: bytes
public_key_length: int
public_key: bytes
__init__(signature_and_hash_algorithm: bytes, signature_length: int, signature: bytes, public_key_length: int, public_key: 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
ticket_lifetime_hint: int | None
ticket: bytes | None
__init__(length: int, ticket_lifetime_hint: int | None = None, ticket: bytes | None = None) 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.

data: str
data_length: int | None
subject_name: str | None
issuer_name: str | None
serial_number: str | None
not_valid_before: str | None
__init__(data: str, data_length: int | None = None, subject_name: str | None = None, issuer_name: str | None = None, serial_number: str | None = None, not_valid_before: str | None = None) 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
certificate_types: bytes | None
signature_hash_algorithms: bytes | None
__init__(certificate_request_length: int, certificate_types: bytes | None = None, signature_hash_algorithms: bytes | None = None) 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
class mtf.network_port.tls.helpers.messages.ApplicationData

Represents the ApplicationData message in TLS.

Attributes:

data (bytes): The encrypted application data transmitted after the TLS handshake.

data: bytes
__init__(data: bytes) None