OpenTTD Source 20241224-master-gee860a5c8e
|
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. | |
virtual ResponseResult | ReceiveResponse (struct Packet &p)=0 |
Read the response from the client. | |
virtual void | SendEnableEncryption (struct Packet &p)=0 |
Create the request to enable encryption to the client. | |
virtual bool | CanBeUsed () const =0 |
Checks whether this handler can be used with the current configuration. | |
virtual std::string | GetPeerPublicKey () const =0 |
Get the public key the peer provided during the authentication. | |
Public Member Functions inherited from NetworkAuthenticationHandler | |
virtual std::string_view | GetName () const =0 |
Get the name of the handler for debug messages. | |
virtual NetworkAuthenticationMethod | GetAuthenticationMethod () const =0 |
Get the method this handler is providing functionality for. | |
virtual std::unique_ptr< NetworkEncryptionHandler > | CreateClientToServerEncryptionHandler () const =0 |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server. | |
virtual std::unique_ptr< NetworkEncryptionHandler > | CreateServerToClientEncryptionHandler () const =0 |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client. | |
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. | |
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 X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.
|
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 ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE(), and ServerNetworkGameSocketHandler::SendAuthRequest().
|
pure virtual |
Get the public key the peer provided during the authentication.
Implemented in X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.
|
pure virtual |
Read the response from the client.
p | The packet to read the response from. |
ResponseResult
describing the result. Implemented in X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.
|
pure virtual |
Create the request to enable encryption to the client.
p | The packet to write the enable encryption request to. |
Implemented in X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.
|
pure virtual |
Create the request to send to the client.
p | The packet to write the request to. |
Implemented in X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.