ServerHelloGenerator

class mtf.network_port.tls.tls_helpers.ServerHelloGenerator

Generator for TLS handshake protocol ‘Server Hello’ messages.

This class is responsible for constructing and generating ‘Server Hello’ messages during the TLS handshake process, based on the specified configuration such as supported ciphers, extensions, and protocol version.

Attributes:

version (Optional[ProtocolVersion]): The TLS version to use in the Server Hello message. ciphers (List[Any]): A list of supported cipher suites. extensions (Optional[Dict[TlsExtensionType, Union[Callable, TLSExtension]]]):

A dictionary mapping extension types to their corresponding generators or objects.

session_id (Optional[bytes]): The session ID to include in the Server Hello message. random (Optional[bytes]): Random data for the Server Hello message. compression (List[int]): A list of supported compression methods (typically [0]). ssl2 (bool): Flag indicating whether to use SSLv2-compatible format. modifiers (Optional[List[Callable]]): A list of modifier functions for custom processing.

__init__(ciphers: List[Any] | None = None, extensions: dict[TlsExtensionType, Callable | TLSExtension] | None = None, version: ProtocolVersion | None = None, session_id: bytearray | None = None, random: bytearray | None = None, compression: List[int] | None = None, ssl2: bool = False, modifiers: List[Callable] | None = None)

Initializes the ServerHelloGenerator with the given parameters.

Args:

ciphers (Optional[List[Any]]): List of cipher suites to include in the Server Hello. extensions (Optional[Dict[TlsExtensionType, Union[Callable, TLSExtension]]]):

Dictionary of extensions to include.

version (Optional[ProtocolVersion]): The TLS version to use. session_id (Optional[bytearray]): The session ID for the Server Hello. random (Optional[bytearray]): Random data for the Server Hello. compression (Optional[List[int]]): Supported compression methods. ssl2 (bool): If True, generates SSLv2-compatible messages. modifiers (Optional[List[Callable]]): List of functions to modify the message.

generate(state: ConnectionState)

Generates the Server Hello message based on the current state and configuration.

Args:

state (ConnectionState): The current state of the handshake process.

Returns:

ServerHello: The generated Server Hello message.

add_child(child)

Sets the parameter as the child of the node

Returns:

the child node

get_all_siblings()

Return iterator with all siblings of node

Return type:

iterator

is_command()

Define object as a generator node.

is_expect()

Define object as a generator node.

is_generator()

Define object as a generator node.

post_send(state)

Update handshake hashes after sending.