OpenTTD Source  20241125-master-g5b02f51e17
NetworkAuthenticationServerHandler Class Referenceabstract

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

#include <network_crypto.h>

Inheritance diagram for NetworkAuthenticationServerHandler:
NetworkAuthenticationHandler CombinedAuthenticationServerHandler X25519AuthorizedKeyServerHandler X25519KeyExchangeOnlyServerHandler X25519PAKEServerHandler

Public Types

enum  ResponseResult { AUTHENTICATED , NOT_AUTHENTICATED , RETRY_NEXT_METHOD }
 The processing result of receiving a response. More...
 

Public Member Functions

virtual void SendRequest (struct Packet &p)=0
 Create the request to send to the client. More...
 
virtual ResponseResult ReceiveResponse (struct Packet &p)=0
 Read the response from the client. More...
 
virtual void SendEnableEncryption (struct Packet &p)=0
 Create the request to enable encryption to the client. More...
 
virtual bool CanBeUsed () const =0
 Checks whether this handler can be used with the current configuration. More...
 
virtual std::string GetPeerPublicKey () const =0
 Get the public key the peer provided during the authentication. 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 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. More...
 

Detailed Description

Base class for server side cryptographic authentication handlers.

Definition at line 258 of file network_crypto.h.

Member Enumeration Documentation

◆ ResponseResult

The processing result of receiving a response.

Enumerator
AUTHENTICATED 

The client was authenticated successfully.

NOT_AUTHENTICATED 

All authentications for this handler have been exhausted.

RETRY_NEXT_METHOD 

The client failed to authenticate, but there is another method to try.

Definition at line 261 of file network_crypto.h.

Member Function Documentation

◆ CanBeUsed()

virtual bool NetworkAuthenticationServerHandler::CanBeUsed ( ) const
pure virtual

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.

Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.

◆ Create()

std::unique_ptr< NetworkAuthenticationServerHandler > NetworkAuthenticationServerHandler::Create ( const NetworkAuthenticationPasswordProvider password_provider,
const NetworkAuthenticationAuthorizedKeyHandler authorized_key_handler,
NetworkAuthenticationMethodMask  client_supported_method_mask = ~static_cast<NetworkAuthenticationMethodMask>(0) 
)
static

Create a NetworkAuthenticationServerHandler.

Parameters
password_providerCallback to provide the password handling. Must remain valid until the authentication has succeeded or failed. Can be nullptr to skip password checks.
authorized_key_handlerCallback to provide the authorized key handling. Must remain valid until the authentication has succeeded or failed. Can be nullptr to skip authorized key checks.
client_supported_method_maskBitmask of the methods that are supported by the client. Defaults to support of all methods.

Definition at line 478 of file network_crypto.cpp.

References X25519SecretKey::CreateRandom(), HasBit(), NETWORK_AUTH_METHOD_X25519_AUTHORIZED_KEY, NETWORK_AUTH_METHOD_X25519_KEY_EXCHANGE_ONLY, and NETWORK_AUTH_METHOD_X25519_PAKE.

Referenced by ServerNetworkGameSocketHandler::SendAuthRequest().

◆ GetPeerPublicKey()

virtual std::string NetworkAuthenticationServerHandler::GetPeerPublicKey ( ) const
pure virtual

Get the public key the peer provided during the authentication.

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

Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.

◆ ReceiveResponse()

virtual ResponseResult NetworkAuthenticationServerHandler::ReceiveResponse ( struct Packet p)
pure virtual

Read the response from the client.

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

Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.

◆ SendEnableEncryption()

virtual void NetworkAuthenticationServerHandler::SendEnableEncryption ( struct Packet p)
pure virtual

Create the request to enable encryption to the client.

Parameters
pThe packet to write the enable encryption request to.

Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.

◆ SendRequest()

virtual void NetworkAuthenticationServerHandler::SendRequest ( struct Packet p)
pure virtual

Create the request to send to the client.

Parameters
pThe packet to write the request to.

Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.


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