Tls Helpers Module
- mtf.network_port.tls.tls_helpers.render_template(template_name: str, output_name: str, context: dict) str
Renders a Jinja2 template and writes it to a file.
- Args:
template_name (str): Name of the template file. output_name (str): Name of the output XML file. context (dict): Context dictionary for rendering the template.
- Returns:
str: The file path to the generated XML configuration.
- mtf.network_port.tls.tls_helpers.prepare_server_config(**kwargs) str
Generates a server XML configuration using Jinja2 templates.
- mtf.network_port.tls.tls_helpers.prepare_client_config(**kwargs) str
Generates a client XML configuration using Jinja2 templates.
- class mtf.network_port.tls.tls_helpers.BaseTlsManager
- __init__(target_ip: str, target_port: int, psk_key: str, psk_identity: str, cipher: str | List[str] | None, dtls_version: ProtocolVersion, timeout: float, send_handshake_messages_within_single_record: bool = False, tls_attacker_apps_path: str | None = None, psk_hint: str | None = None, source_ip: str | None = None, source_port: int | None = None)
- prepare_ciphers_for_argument(ciphers: str | List[str]) str
Prepares a string representation of the cipher(s) to be passed as an argument to the TLS-Attacker client.
- Args:
ciphers (Union[str, List[str]]): A single cipher (as a string) or a list of ciphers.
- Returns:
str: A comma-separated string of cipher names in IANA format.
- add_extension(extension_type: TlsExtensionType, value: Any | None = None, status: bool | None = True) None
- set_extension_property(property_name: str, value: Any) None
Abstract method to set extension properties.
- send_action(message_types: list[TlsMessage], message_properties: dict | None = None, with_extensions=True) None
Dynamically sends a series of TLS messages from/to the server/client during a handshake, with optional properties for each message type.
- Args:
message_types (list[TlsMessage]): A list of TlsMessage enum members representing the message types to send. message_properties (dict, optional): A dictionary where keys are TlsMessage types and values are
dictionaries of properties to set (e.g., {‘verify_data’: b’…’}).
- get_config(message_type: TlsMessage)
Should be implemented by subclasses to provide the appropriate configuration.
- receive_action(message_types: list[TlsMessage]) None
Dynamically receives a series of DTLS messages from/to the server/client during a handshake.
- Args:
message_types (list[TlsMessage]): A list of TlsMessage enum members representing the message types to receive.
- add_wait_action(delay_ms: int) None
Adds a wait action to pause for the specified duration.
- Args:
delay_ms (int): The delay in milliseconds to wait.
- shutdown() None
Shuts down the JVM if it is currently running.
- class mtf.network_port.tls.tls_helpers.TlsClientManager
- __init__(**kwargs)
- set_extension_property(property_name: str, value: Any) None
Sets a property for the TLS client.
- get_config(message_type: TlsMessage)
Provides the client-specific configuration.
- start_client()
Starts the TLS-Attacker client.
- add_extension(extension_type: TlsExtensionType, value: Any | None = None, status: bool | None = True) None
- add_wait_action(delay_ms: int) None
Adds a wait action to pause for the specified duration.
- Args:
delay_ms (int): The delay in milliseconds to wait.
- prepare_ciphers_for_argument(ciphers: str | List[str]) str
Prepares a string representation of the cipher(s) to be passed as an argument to the TLS-Attacker client.
- Args:
ciphers (Union[str, List[str]]): A single cipher (as a string) or a list of ciphers.
- Returns:
str: A comma-separated string of cipher names in IANA format.
- receive_action(message_types: list[TlsMessage]) None
Dynamically receives a series of DTLS messages from/to the server/client during a handshake.
- Args:
message_types (list[TlsMessage]): A list of TlsMessage enum members representing the message types to receive.
- send_action(message_types: list[TlsMessage], message_properties: dict | None = None, with_extensions=True) None
Dynamically sends a series of TLS messages from/to the server/client during a handshake, with optional properties for each message type.
- Args:
message_types (list[TlsMessage]): A list of TlsMessage enum members representing the message types to send. message_properties (dict, optional): A dictionary where keys are TlsMessage types and values are
dictionaries of properties to set (e.g., {‘verify_data’: b’…’}).
- shutdown() None
Shuts down the JVM if it is currently running.
- class mtf.network_port.tls.tls_helpers.TlsServerManager
- __init__(**kwargs)
- set_extension_property(property_name: str, value: Any) None
Sets a property for the TLS server.
- get_config(message_type: TlsMessage)
Provides the server-specific configuration.
- start_server()
Starts the TLS-Attacker server.
- add_extension(extension_type: TlsExtensionType, value: Any | None = None, status: bool | None = True) None
- add_wait_action(delay_ms: int) None
Adds a wait action to pause for the specified duration.
- Args:
delay_ms (int): The delay in milliseconds to wait.
- prepare_ciphers_for_argument(ciphers: str | List[str]) str
Prepares a string representation of the cipher(s) to be passed as an argument to the TLS-Attacker client.
- Args:
ciphers (Union[str, List[str]]): A single cipher (as a string) or a list of ciphers.
- Returns:
str: A comma-separated string of cipher names in IANA format.
- receive_action(message_types: list[TlsMessage]) None
Dynamically receives a series of DTLS messages from/to the server/client during a handshake.
- Args:
message_types (list[TlsMessage]): A list of TlsMessage enum members representing the message types to receive.
- send_action(message_types: list[TlsMessage], message_properties: dict | None = None, with_extensions=True) None
Dynamically sends a series of TLS messages from/to the server/client during a handshake, with optional properties for each message type.
- Args:
message_types (list[TlsMessage]): A list of TlsMessage enum members representing the message types to send. message_properties (dict, optional): A dictionary where keys are TlsMessage types and values are
dictionaries of properties to set (e.g., {‘verify_data’: b’…’}).
- shutdown() None
Shuts down the JVM if it is currently running.