MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / SendPassword

Function SendPassword

src/openrct2/network/NetworkBase.cpp:3996–4023  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3994 }
3995
3996 void SendPassword(const std::string& password)
3997 {
3998 auto& network = GetContext()->GetNetwork();
3999 const auto keyPath = GetPrivateKeyPath(Config::Get().network.playerName);
4000 if (!File::Exists(keyPath))
4001 {
4002 LOG_ERROR("Private key %s missing! Restart the game to generate it.", keyPath.c_str());
4003 return;
4004 }
4005 try
4006 {
4007 auto fs = FileStream(keyPath, FileMode::open);
4008 network._key.LoadPrivate(&fs);
4009 }
4010 catch (const std::exception&)
4011 {
4012 LOG_ERROR("Error reading private key from %s.", keyPath.c_str());
4013 return;
4014 }
4015 const std::string pubkey = network._key.PublicKeyString();
4016
4017 std::vector<uint8_t> signature;
4018 network._key.Sign(network._challenge.data(), network._challenge.size(), signature);
4019 // Don't keep private key in memory. There's no need and it may get leaked
4020 // when process dump gets collected at some point in future.
4021 network._key.Unload();
4022 network.Client_Send_AUTH(Config::Get().network.playerName, password, pubkey, signature);
4023 }
4024
4025 void SetPassword(const char* password)
4026 {

Callers 1

onTextInputMethod · 0.85

Calls 11

GetContextFunction · 0.85
GetPrivateKeyPathFunction · 0.85
ExistsFunction · 0.85
FileStreamClass · 0.85
LoadPrivateMethod · 0.80
PublicKeyStringMethod · 0.80
SignMethod · 0.80
Client_Send_AUTHMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
UnloadMethod · 0.45

Tested by

no test coverage detected