* Get the secret key from the given string. If that is not a valid secret key, reset it with a random one. * Furthermore update the public key so it is always in sync with the private key. * @param secret_key The secret key to read/validate/fix. * @param public_key The public key to update. * @return The valid secret key. */ static */
| 332 | * @return The valid secret key. |
| 333 | */ |
| 334 | /* static */ X25519SecretKey X25519AuthorizedKeyClientHandler::GetValidSecretKeyAndUpdatePublicKey(std::string &secret_key, std::string &public_key) |
| 335 | { |
| 336 | X25519SecretKey key{}; |
| 337 | if (!ConvertHexToBytes(secret_key, key)) { |
| 338 | if (secret_key.empty()) { |
| 339 | Debug(net, 3, "[crypto] Creating a new random key"); |
| 340 | } else { |
| 341 | Debug(net, 0, "[crypto] Found invalid secret key, creating a new random key"); |
| 342 | } |
| 343 | key = X25519SecretKey::CreateRandom(); |
| 344 | secret_key = FormatArrayAsHex(key); |
| 345 | } |
| 346 | |
| 347 | public_key = FormatArrayAsHex(key.CreatePublicKey()); |
| 348 | return key; |
| 349 | } |
| 350 | |
| 351 | /* virtual */ NetworkAuthenticationServerHandler::ResponseResult X25519AuthorizedKeyServerHandler::ReceiveResponse(Packet &p) |
| 352 | { |
nothing calls this directly
no test coverage detected