OpenTTD Source: NetworkAuthenticationServerHandler Class Reference

OpenTTD Source 15.0-beta1

Public Types | Public Member Functions | Static Public Member Functions
NetworkAuthenticationServerHandler Class Referenceabstract

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

`#include <network_crypto.h>`

Inheritance diagram for NetworkAuthenticationServerHandler:

## 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.

## Detailed Description

Base class for server side cryptographic authentication handlers.

Definition at line 258 of file network_crypto.h.

## Member Enumeration Documentation

## ◆ ResponseResult

enum NetworkAuthenticationServerHandler::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 X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.

## ◆ 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_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().

## ◆ 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 X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.

## ◆ ReceiveResponse()

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

Read the response from the client.

Parameters

  p | The packet to read the response from.

Returns
  The `ResponseResult` describing the result.

Implemented in X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.

## ◆ SendEnableEncryption()

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

Create the request to enable encryption to the client.

Parameters

  p | The packet to write the enable encryption request to.

Implemented in X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.

## ◆ SendRequest()

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

Create the request to send to the client.

Parameters

  p | The packet to write the request to.

Implemented in X25519KeyExchangeOnlyServerHandler, X25519PAKEServerHandler, X25519AuthorizedKeyServerHandler, and CombinedAuthenticationServerHandler.

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

- src/network/network_crypto.h
- src/network/network_crypto.cpp