Network: Change protocol for game/rcon/settings password auth

Instead of sending a hash, do a DH/X25519 key exchange
using the password.
This also allows authenticating the associated rcon payload and response.
This commit is contained in:
Jonathan G Rennison
2023-06-15 21:32:15 +01:00
parent 9042eb338f
commit 3d2dc77aa2
7 changed files with 280 additions and 81 deletions

View File

@@ -122,6 +122,20 @@ struct NetworkGameList *NetworkAddServer(const std::string &connection_string, b
void NetworkRebuildHostList();
void UpdateNetworkGameWindow();
struct NetworkGameKeys {
byte x25519_priv_key[32]; ///< x25519 key: private part
byte x25519_pub_key[32]; ///< x25519 key: public part
bool inited = false;
void Initialise();
};
struct NetworkSharedSecrets {
byte shared_data[64];
~NetworkSharedSecrets();
};
/* From network_command.cpp */
/**
* Everything we need to know about a command to be able to execute it.
@@ -148,6 +162,7 @@ StringID GetNetworkErrorMsg(NetworkErrorCode err);
bool NetworkMakeClientNameUnique(std::string &new_name);
std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32 password_game_seed);
std::vector<uint8> GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64 password_game_seed);
std::string BytesToHexString(const byte *data, uint length);
std::string NetworkGenerateRandomKeyString(uint bytes);
std::string_view ParseCompanyFromConnectionString(const std::string &connection_string, CompanyID *company_id);