OpenTTD Source 20241224-master-gf74b0cf984
|
Container for the keys that derived from the X25519 key exchange mechanism. More...
#include <network_crypto_internal.h>
Public Member Functions | |
~X25519DerivedKeys () | |
Ensure the derived keys do not get leaked when we're done with it. | |
std::span< const uint8_t > | ClientToServer () const |
Get the key to encrypt or decrypt a message sent from the client to the server. | |
std::span< const uint8_t > | ServerToClient () const |
Get the key to encrypt or decrypt a message sent from the server to the client. | |
bool | Exchange (const X25519PublicKey &peer_public_key, X25519KeyExchangeSide side, const X25519SecretKey &our_secret_key, const X25519PublicKey &our_public_key, std::string_view extra_payload) |
Perform the actual key exchange. | |
Private Attributes | |
std::array< uint8_t, X25519_KEY_SIZE+X25519_KEY_SIZE > | keys |
Single contiguous buffer to store the derived keys in, as they are generated as a single hash. | |
Container for the keys that derived from the X25519 key exchange mechanism.
This mechanism derives a key to encrypt both the client-to-server and a key to encrypt server-to-client communication.
Definition at line 61 of file network_crypto_internal.h.
X25519DerivedKeys::~X25519DerivedKeys | ( | ) |
Ensure the derived keys do not get leaked when we're done with it.
Definition at line 32 of file network_crypto.cpp.
References crypto_wipe(), and keys.
std::span< const uint8_t > X25519DerivedKeys::ClientToServer | ( | ) | const |
Get the key to encrypt or decrypt a message sent from the client to the server.
Definition at line 41 of file network_crypto.cpp.
References keys, and X25519_KEY_SIZE.
bool X25519DerivedKeys::Exchange | ( | const X25519PublicKey & | peer_public_key, |
X25519KeyExchangeSide | side, | ||
const X25519SecretKey & | our_secret_key, | ||
const X25519PublicKey & | our_public_key, | ||
std::string_view | extra_payload | ||
) |
Perform the actual key exchange.
peer_public_key | The public key chosen by the other participant of the key exchange. |
side | Whether we are the client or server; used to hash the public key of us and the peer in the right order. |
our_secret_key | The secret key of us. |
our_public_key | The public key of us. |
extra_payload | Extra payload to put into the hash function to create the derived keys. |
Definition at line 64 of file network_crypto.cpp.
References CLIENT, keys, and SERVER.
Referenced by X25519AuthenticationHandler::ReceiveResponse(), and X25519AuthenticationHandler::SendResponse().
std::span< const uint8_t > X25519DerivedKeys::ServerToClient | ( | ) | const |
Get the key to encrypt or decrypt a message sent from the server to the client.
Definition at line 50 of file network_crypto.cpp.
References keys, and X25519_KEY_SIZE.
|
private |
Single contiguous buffer to store the derived keys in, as they are generated as a single hash.
Definition at line 64 of file network_crypto_internal.h.
Referenced by ClientToServer(), Exchange(), ServerToClient(), and ~X25519DerivedKeys().