OpenTTD Source
20241125-master-g5b02f51e17
|
Base class for server side cryptographic authentication handlers. More...
#include <network_crypto.h>
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< NetworkEncryptionHandler > | CreateClientToServerEncryptionHandler () const =0 |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server. More... | |
virtual std::unique_ptr< NetworkEncryptionHandler > | CreateServerToClientEncryptionHandler () 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< NetworkAuthenticationServerHandler > | Create (const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask=~static_cast< NetworkAuthenticationMethodMask >(0)) |
Create a NetworkAuthenticationServerHandler. More... | |
Base class for server side cryptographic authentication handlers.
Definition at line 258 of file network_crypto.h.
The processing result of receiving a response.
Definition at line 261 of file network_crypto.h.
|
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.
Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.
|
static |
Create a NetworkAuthenticationServerHandler.
password_provider | Callback to provide the password handling. Must remain valid until the authentication has succeeded or failed. Can be nullptr to skip password checks. |
authorized_key_handler | Callback 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_mask | Bitmask 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().
|
pure virtual |
Get the public key the peer provided during the authentication.
Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.
|
pure virtual |
Read the response from the client.
p | The packet to read the response from. |
ResponseResult
describing the result. Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.
|
pure virtual |
Create the request to enable encryption to the client.
p | The packet to write the enable encryption request to. |
Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.
|
pure virtual |
Create the request to send to the client.
p | The packet to write the request to. |
Implemented in CombinedAuthenticationServerHandler, X25519AuthorizedKeyServerHandler, X25519PAKEServerHandler, and X25519KeyExchangeOnlyServerHandler.