MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SendResponse

Method SendResponse

src/network/network_crypto.cpp:219–238  ·  view source on GitHub ↗

* Perform the key exchange, and when that is correct fill the \c Packet with the appropriate data. * @param p The packet that has to be sent. * @param derived_key_extra_payload The extra payload to pass to the key exchange. * @return Whether the key exchange was successful or not. */

Source from the content-addressed store, hash-verified

217 * @return Whether the key exchange was successful or not.
218 */
219bool X25519AuthenticationHandler::SendResponse(Packet &p, std::string_view derived_key_extra_payload)
220{
221 if (!this->derived_keys.Exchange(this->peer_public_key, X25519KeyExchangeSide::CLIENT,
222 this->our_secret_key, this->our_public_key, derived_key_extra_payload)) {
223 Debug(net, 0, "[crypto] Peer sent an illegal public key; authentication aborted.");
224 return false;
225 }
226
227 X25519KeyExchangeMessage message;
228 RandomBytesWithFallback(message);
229 X25519Mac mac;
230
231 crypto_aead_lock(message.data(), mac.data(), this->derived_keys.ClientToServer().data(), this->key_exchange_nonce.data(),
232 this->our_public_key.data(), this->our_public_key.size(), message.data(), message.size());
233
234 p.Send_bytes(this->our_public_key);
235 p.Send_bytes(mac);
236 p.Send_bytes(message);
237 return true;
238}
239
240/**
241 * Get the public key the peer provided for the key exchange.

Callers 1

ReplyMethod · 0.45

Calls 8

GetNameMethod · 0.95
RandomBytesWithFallbackFunction · 0.85
crypto_aead_lockFunction · 0.85
ExchangeMethod · 0.80
ClientToServerMethod · 0.80
Send_bytesMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected