OpenTTD Source 20241224-master-gee860a5c8e
test_network_crypto.cpp File Reference

Tests for network related crypto functions. More...

#include "../stdafx.h"
#include "../3rdparty/catch2/catch.hpp"
#include "../core/format.hpp"
#include "../network/network_crypto_internal.h"
#include "../network/core/packet.h"
#include "../string_func.h"

Go to the source code of this file.

Data Structures

class  MockNetworkSocketHandler
 
class  TestPasswordRequestHandler
 

Functions

static std::tuple< Packet, bool > CreatePacketForReading (Packet &source, MockNetworkSocketHandler *socket_handler)
 
static void TestAuthentication (NetworkAuthenticationServerHandler &server, NetworkAuthenticationClientHandler &client, NetworkAuthenticationServerHandler::ResponseResult expected_response_result, NetworkAuthenticationClientHandler::RequestResult expected_request_result)
 
 TEST_CASE ("Authentication_KeyExchangeOnly")
 
static void TestAuthenticationPAKE (std::string server_password, std::string client_password, NetworkAuthenticationServerHandler::ResponseResult expected_response_result)
 
 TEST_CASE ("Authentication_PAKE")
 
static void TestAuthenticationAuthorizedKey (const X25519SecretKey &client_secret_key, const X25519PublicKey &server_expected_public_key, NetworkAuthenticationServerHandler::ResponseResult expected_response_result)
 
 TEST_CASE ("Authentication_AuthorizedKey")
 
 TEST_CASE ("Authentication_Combined")
 
static void CheckEncryption (MockNetworkSocketHandler *sending_socket_handler, MockNetworkSocketHandler *receiving_socket_handler)
 
 TEST_CASE ("Encryption handling")
 

Variables

static MockNetworkSocketHandler mock_socket_handler
 

Detailed Description

Tests for network related crypto functions.

Definition in file test_network_crypto.cpp.

Function Documentation

◆ CheckEncryption()

static void CheckEncryption ( MockNetworkSocketHandler sending_socket_handler,
MockNetworkSocketHandler receiving_socket_handler 
)
static

Definition at line 215 of file test_network_crypto.cpp.

◆ CreatePacketForReading()

static std::tuple< Packet, bool > CreatePacketForReading ( Packet source,
MockNetworkSocketHandler socket_handler 
)
static

Definition at line 34 of file test_network_crypto.cpp.

◆ TEST_CASE() [1/5]

TEST_CASE ( "Authentication_AuthorizedKey"  )

Definition at line 132 of file test_network_crypto.cpp.

◆ TEST_CASE() [2/5]

TEST_CASE ( "Authentication_Combined"  )

Definition at line 148 of file test_network_crypto.cpp.

◆ TEST_CASE() [3/5]

TEST_CASE ( "Authentication_KeyExchangeOnly"  )

Definition at line 84 of file test_network_crypto.cpp.

◆ TEST_CASE() [4/5]

TEST_CASE ( "Authentication_PAKE"  )

Definition at line 103 of file test_network_crypto.cpp.

◆ TEST_CASE() [5/5]

TEST_CASE ( "Encryption handling"  )

Definition at line 246 of file test_network_crypto.cpp.

◆ TestAuthentication()

static void TestAuthentication ( NetworkAuthenticationServerHandler server,
NetworkAuthenticationClientHandler client,
NetworkAuthenticationServerHandler::ResponseResult  expected_response_result,
NetworkAuthenticationClientHandler::RequestResult  expected_request_result 
)
static

Definition at line 63 of file test_network_crypto.cpp.

◆ TestAuthenticationAuthorizedKey()

static void TestAuthenticationAuthorizedKey ( const X25519SecretKey client_secret_key,
const X25519PublicKey server_expected_public_key,
NetworkAuthenticationServerHandler::ResponseResult  expected_response_result 
)
static

Definition at line 119 of file test_network_crypto.cpp.

◆ TestAuthenticationPAKE()

static void TestAuthenticationPAKE ( std::string  server_password,
std::string  client_password,
NetworkAuthenticationServerHandler::ResponseResult  expected_response_result 
)
static

Definition at line 93 of file test_network_crypto.cpp.

Variable Documentation

◆ mock_socket_handler

MockNetworkSocketHandler mock_socket_handler
static

Definition at line 32 of file test_network_crypto.cpp.