OpenTTD Source: NetworkAuthenticationClientHandler Class Reference

OpenTTD Source 15.0-RC2

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

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

`#include <network_crypto.h>`

Inheritance diagram for NetworkAuthenticationClientHandler:

## Public Types
enum class | RequestResult : uint8_t { AwaitUserInput , ReadyForResponse , 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.
virtual bool | SendResponse (struct Packet &p)=0
| Create the response to send to the server.
virtual bool | ReceiveEnableEncryption (struct Packet &p)=0
| Read the request to enable encryption from the server.
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 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.
static std::unique_ptr< NetworkAuthenticationClientHandler > | Create (std::shared_ptr< NetworkAuthenticationPasswordRequestHandler > password_handler, std::string &secret_key, std::string &public_key)
| Create a NetworkAuthenticationClientHandler.

## Detailed Description

Base class for client side cryptographic authentication handlers.

Definition at line 222 of file network_crypto.h.

## Member Enumeration Documentation

## ◆ RequestResult

enum class NetworkAuthenticationClientHandler::RequestResult : uint8_t
| strong

The processing result of receiving a request.

Enumerator
AwaitUserInput | We have requested some user input, but must wait on that.
ReadyForResponse | 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_handler | The handler for when a request for password needs to be passed on to the user.
  secret_key | The location where the secret key is stored; can be overwritten when invalid.
  public_key | The 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_key | The location where the secret key is stored; can be overwritten when invalid.
  public_key | The 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

  p | The request from the server.

Implemented in X25519KeyExchangeOnlyClientHandler, X25519PAKEClientHandler, X25519AuthorizedKeyClientHandler, and CombinedAuthenticationClientHandler.

Referenced by CombinedAuthenticationClientHandler::ReceiveEnableEncryption().

## ◆ ReceiveRequest()

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

Read a request from the server.

Parameters

  p | The packet to read the request from.

Returns
  True when valid, otherwise false.

Implemented in X25519KeyExchangeOnlyClientHandler, X25519PAKEClientHandler, X25519AuthorizedKeyClientHandler, and CombinedAuthenticationClientHandler.

Referenced by CombinedAuthenticationClientHandler::ReceiveRequest().

## ◆ SendResponse()

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

Create the response to send to the server.

Parameters

  p | The packet to write the response from.

Returns
  True when a valid packet was made, otherwise false.

Implemented in X25519KeyExchangeOnlyClientHandler, X25519PAKEClientHandler, X25519AuthorizedKeyClientHandler, and CombinedAuthenticationClientHandler.

Referenced by CombinedAuthenticationClientHandler::SendResponse().

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

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