OpenTTD Source  20241109-master-g5e4f8db7d6
NetworkAuthenticationClientHandler Class Referenceabstract

Base class for client side cryptographic authentication handlers. More...

#include <network_crypto.h>

Inheritance diagram for NetworkAuthenticationClientHandler:
NetworkAuthenticationHandler CombinedAuthenticationClientHandler X25519AuthorizedKeyClientHandler X25519KeyExchangeOnlyClientHandler X25519PAKEClientHandler

Public Types

enum  RequestResult { AWAIT_USER_INPUT , READY_FOR_RESPONSE , INVALID }
 The processing result of receiving a request. More...
 

Public Member Functions

virtual RequestResult ReceiveRequest (struct Packet &p)=0
 Read a request from the server. More...
 
virtual bool SendResponse (struct Packet &p)=0
 Create the response to send to the server. More...
 
virtual bool ReceiveEnableEncryption (struct Packet &p)=0
 Read the request to enable encryption from the server. More...
 
- Public Member Functions inherited from NetworkAuthenticationHandler
virtual std::string_view GetName () const =0
 Get the name of the handler for debug messages. More...
 
virtual NetworkAuthenticationMethod GetAuthenticationMethod () const =0
 Get the method this handler is providing functionality for. More...
 
virtual std::unique_ptr< NetworkEncryptionHandlerCreateClientToServerEncryptionHandler () const =0
 Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server. More...
 
virtual std::unique_ptr< NetworkEncryptionHandlerCreateServerToClientEncryptionHandler () const =0
 Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client. More...
 

Static Public Member Functions

static void EnsureValidSecretKeyAndUpdatePublicKey (std::string &secret_key, std::string &public_key)
 Ensures that the given secret key is valid, and when not overwrite it with a valid secret key. More...
 
static std::unique_ptr< NetworkAuthenticationClientHandlerCreate (std::shared_ptr< NetworkAuthenticationPasswordRequestHandler > password_handler, std::string &secret_key, std::string &public_key)
 Create a NetworkAuthenticationClientHandler. More...
 

Detailed Description

Base class for client side cryptographic authentication handlers.

Definition at line 222 of file network_crypto.h.

Member Enumeration Documentation

◆ RequestResult

The processing result of receiving a request.

Enumerator
AWAIT_USER_INPUT 

We have requested some user input, but must wait on that.

READY_FOR_RESPONSE 

We do not have to wait for user input, and can immediately respond to the server.

INVALID 

We have received an invalid request.

Definition at line 225 of file network_crypto.h.

Member Function Documentation

◆ Create()

std::unique_ptr< NetworkAuthenticationClientHandler > NetworkAuthenticationClientHandler::Create ( std::shared_ptr< NetworkAuthenticationPasswordRequestHandler password_handler,
std::string &  secret_key,
std::string &  public_key 
)
static

Create a NetworkAuthenticationClientHandler.

Parameters
password_handlerThe handler for when a request for password needs to be passed on to the user.
secret_keyThe location where the secret key is stored; can be overwritten when invalid.
public_keyThe location where the public key is stored; can be overwritten when invalid.

Definition at line 462 of file network_crypto.cpp.

References X25519AuthorizedKeyClientHandler::GetValidSecretKeyAndUpdatePublicKey().

Referenced by ClientNetworkGameSocketHandler::Receive_SERVER_AUTH_REQUEST().

◆ EnsureValidSecretKeyAndUpdatePublicKey()

void NetworkAuthenticationClientHandler::EnsureValidSecretKeyAndUpdatePublicKey ( std::string &  secret_key,
std::string &  public_key 
)
static

Ensures that the given secret key is valid, and when not overwrite it with a valid secret key.

Then update the public key to be associated with the secret key.

Parameters
secret_keyThe location where the secret key is stored; can be overwritten when invalid.
public_keyThe location where the public key is stored; can be overwritten when invalid.

Definition at line 451 of file network_crypto.cpp.

References X25519AuthorizedKeyClientHandler::GetValidSecretKeyAndUpdatePublicKey().

◆ ReceiveEnableEncryption()

virtual bool NetworkAuthenticationClientHandler::ReceiveEnableEncryption ( struct Packet p)
pure virtual

Read the request to enable encryption from the server.

Parameters
pThe request from the server.

Implemented in CombinedAuthenticationClientHandler, X25519AuthorizedKeyClientHandler, X25519PAKEClientHandler, and X25519KeyExchangeOnlyClientHandler.

Referenced by CombinedAuthenticationClientHandler::ReceiveEnableEncryption().

◆ ReceiveRequest()

virtual RequestResult NetworkAuthenticationClientHandler::ReceiveRequest ( struct Packet p)
pure virtual

Read a request from the server.

Parameters
pThe packet to read the request from.
Returns
True when valid, otherwise false.

Implemented in CombinedAuthenticationClientHandler, X25519AuthorizedKeyClientHandler, X25519PAKEClientHandler, and X25519KeyExchangeOnlyClientHandler.

Referenced by CombinedAuthenticationClientHandler::ReceiveRequest().

◆ SendResponse()

virtual bool NetworkAuthenticationClientHandler::SendResponse ( struct Packet p)
pure virtual

Create the response to send to the server.

Parameters
pThe packet to write the response from.
Returns
True when a valid packet was made, otherwise false.

Implemented in CombinedAuthenticationClientHandler, X25519AuthorizedKeyClientHandler, X25519PAKEClientHandler, and X25519KeyExchangeOnlyClientHandler.

Referenced by CombinedAuthenticationClientHandler::SendResponse().


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