| 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 | { |
no test coverage detected