OpenTTD Source 20241224-master-gee860a5c8e
X25519PAKEServerHandler Class Reference

Server side handler for using X25519 with a password-authenticated key exchange. More...

#include <network_crypto_internal.h>

Inheritance diagram for X25519PAKEServerHandler:
X25519AuthenticationHandler NetworkAuthenticationServerHandler NetworkAuthenticationHandler

Public Member Functions

 X25519PAKEServerHandler (const X25519SecretKey &secret_key, const NetworkAuthenticationPasswordProvider *password_provider)
 Create the handler with the given password provider.
 
virtual void SendRequest (struct Packet &p) override
 Create the request to send to the client.
 
virtual ResponseResult ReceiveResponse (struct Packet &p) override
 Read the response from the client.
 
virtual std::string_view GetName () const override
 Get the name of the handler for debug messages.
 
virtual NetworkAuthenticationMethod GetAuthenticationMethod () const override
 Get the method this handler is providing functionality for.
 
virtual bool CanBeUsed () const override
 Checks whether this handler can be used with the current configuration.
 
virtual std::string GetPeerPublicKey () const override
 Get the public key the peer provided during the authentication.
 
virtual void SendEnableEncryption (struct Packet &p) override
 Create the request to enable encryption to the client.
 
virtual std::unique_ptr< NetworkEncryptionHandlerCreateClientToServerEncryptionHandler () const override
 Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server.
 
virtual std::unique_ptr< NetworkEncryptionHandlerCreateServerToClientEncryptionHandler () const override
 Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client.
 

Private Attributes

const NetworkAuthenticationPasswordProviderpassword_provider
 The password to check against.
 

Additional Inherited Members

- Public Types inherited from NetworkAuthenticationServerHandler
enum  ResponseResult { AUTHENTICATED , NOT_AUTHENTICATED , RETRY_NEXT_METHOD }
 The processing result of receiving a response. More...
 
- Static Public Member Functions inherited from NetworkAuthenticationServerHandler
static std::unique_ptr< NetworkAuthenticationServerHandlerCreate (const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask=~static_cast< NetworkAuthenticationMethodMask >(0))
 Create a NetworkAuthenticationServerHandler.
 
- Protected Types inherited from NetworkAuthenticationServerHandler
enum  ResponseResult { AUTHENTICATED , NOT_AUTHENTICATED , RETRY_NEXT_METHOD }
 The processing result of receiving a response. More...
 
- Protected Member Functions inherited from X25519AuthenticationHandler
 X25519AuthenticationHandler (const X25519SecretKey &secret_key)
 Create the handler, and generate the public keys accordingly.
 
void SendRequest (struct Packet &p)
 
bool ReceiveRequest (struct Packet &p)
 Read the key exchange data from a Packet that came from the server,.
 
bool SendResponse (struct Packet &p, std::string_view derived_key_extra_payload)
 Perform the key exchange, and when that is correct fill the Packet with the appropriate data.
 
NetworkAuthenticationServerHandler::ResponseResult ReceiveResponse (struct Packet &p, std::string_view derived_key_extra_payload)
 Read the key exchange data from a Packet that came from the client, and check whether the client passes the key exchange successfully.
 
std::string GetPeerPublicKey () const
 Get the public key the peer provided for the key exchange.
 
void SendEnableEncryption (struct Packet &p) const
 Send the initial nonce for the encrypted connection.
 
bool ReceiveEnableEncryption (struct Packet &p)
 Receive the initial nonce for the encrypted connection.
 
std::unique_ptr< NetworkEncryptionHandlerCreateClientToServerEncryptionHandler () const
 
std::unique_ptr< NetworkEncryptionHandlerCreateServerToClientEncryptionHandler () const
 
- Static Protected Member Functions inherited from NetworkAuthenticationServerHandler
static std::unique_ptr< NetworkAuthenticationServerHandlerCreate (const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask=~static_cast< NetworkAuthenticationMethodMask >(0))
 Create a NetworkAuthenticationServerHandler.
 

Detailed Description

Server side handler for using X25519 with a password-authenticated key exchange.

This follows the method described in X25519AuthenticationHandler, were the password is the extra payload.

Definition at line 213 of file network_crypto_internal.h.

Constructor & Destructor Documentation

◆ X25519PAKEServerHandler()

X25519PAKEServerHandler::X25519PAKEServerHandler ( const X25519SecretKey secret_key,
const NetworkAuthenticationPasswordProvider password_provider 
)
inline

Create the handler with the given password provider.

Parameters
secret_keyThe secret key to initialize this handler with.
password_providerThe provider for the passwords.

Definition at line 222 of file network_crypto_internal.h.

Member Function Documentation

◆ CanBeUsed()

virtual bool X25519PAKEServerHandler::CanBeUsed ( ) const
inlineoverridevirtual

Checks whether this handler can be used with the current configuration.

For example when there is no password, the handler cannot be used.

Returns
True when this handler can be used.

Implements NetworkAuthenticationServerHandler.

Definition at line 229 of file network_crypto_internal.h.

References NetworkAuthenticationPasswordProvider::GetPassword().

◆ CreateClientToServerEncryptionHandler()

virtual std::unique_ptr< NetworkEncryptionHandler > X25519PAKEServerHandler::CreateClientToServerEncryptionHandler ( ) const
inlineoverridevirtual

Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server.

Returns
The handler for the client to server encryption.

Implements NetworkAuthenticationHandler.

Definition at line 233 of file network_crypto_internal.h.

◆ CreateServerToClientEncryptionHandler()

virtual std::unique_ptr< NetworkEncryptionHandler > X25519PAKEServerHandler::CreateServerToClientEncryptionHandler ( ) const
inlineoverridevirtual

Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client.

Returns
The handler for the server to client encryption.

Implements NetworkAuthenticationHandler.

Definition at line 234 of file network_crypto_internal.h.

◆ GetAuthenticationMethod()

virtual NetworkAuthenticationMethod X25519PAKEServerHandler::GetAuthenticationMethod ( ) const
inlineoverridevirtual

Get the method this handler is providing functionality for.

Returns
The NetworkAuthenticationMethod.

Implements NetworkAuthenticationHandler.

Definition at line 228 of file network_crypto_internal.h.

References NETWORK_AUTH_METHOD_X25519_PAKE.

◆ GetName()

virtual std::string_view X25519PAKEServerHandler::GetName ( ) const
inlineoverridevirtual

Get the name of the handler for debug messages.

Returns
The name of the handler.

Implements NetworkAuthenticationHandler.

Definition at line 227 of file network_crypto_internal.h.

◆ GetPeerPublicKey()

virtual std::string X25519PAKEServerHandler::GetPeerPublicKey ( ) const
inlineoverridevirtual

Get the public key the peer provided during the authentication.

Returns
The hexadecimal string representation of the peer's public key.

Implements NetworkAuthenticationServerHandler.

Definition at line 231 of file network_crypto_internal.h.

References X25519AuthenticationHandler::GetPeerPublicKey().

◆ ReceiveResponse()

virtual ResponseResult X25519PAKEServerHandler::ReceiveResponse ( struct Packet p)
inlineoverridevirtual

Read the response from the client.

Parameters
pThe packet to read the response from.
Returns
The ResponseResult describing the result.

Implements NetworkAuthenticationServerHandler.

Definition at line 225 of file network_crypto_internal.h.

References NetworkAuthenticationPasswordProvider::GetPassword(), and X25519AuthenticationHandler::ReceiveResponse().

◆ SendEnableEncryption()

virtual void X25519PAKEServerHandler::SendEnableEncryption ( struct Packet p)
inlineoverridevirtual

Create the request to enable encryption to the client.

Parameters
pThe packet to write the enable encryption request to.

Implements NetworkAuthenticationServerHandler.

Definition at line 232 of file network_crypto_internal.h.

References X25519AuthenticationHandler::SendEnableEncryption().

◆ SendRequest()

virtual void X25519PAKEServerHandler::SendRequest ( struct Packet p)
inlineoverridevirtual

Create the request to send to the client.

Parameters
pThe packet to write the request to.

Implements NetworkAuthenticationServerHandler.

Definition at line 224 of file network_crypto_internal.h.

Field Documentation

◆ password_provider

const NetworkAuthenticationPasswordProvider* X25519PAKEServerHandler::password_provider
private

The password to check against.

Definition at line 215 of file network_crypto_internal.h.


The documentation for this class was generated from the following file: