| Index: net/quic/test_tools/crypto_test_utils.cc
|
| diff --git a/net/quic/test_tools/crypto_test_utils.cc b/net/quic/test_tools/crypto_test_utils.cc
|
| index c451aa6274714a89dcbec00f247d9c18a09dd9e8..475aec466c44cf34f228be87ba46dc3acc7ed65b 100644
|
| --- a/net/quic/test_tools/crypto_test_utils.cc
|
| +++ b/net/quic/test_tools/crypto_test_utils.cc
|
| @@ -20,6 +20,7 @@
|
| #include "net/quic/core/crypto/channel_id.h"
|
| #include "net/quic/core/crypto/common_cert_set.h"
|
| #include "net/quic/core/crypto/crypto_handshake.h"
|
| +#include "net/quic/core/crypto/crypto_server_config_protobuf.h"
|
| #include "net/quic/core/crypto/quic_crypto_server_config.h"
|
| #include "net/quic/core/crypto/quic_decrypter.h"
|
| #include "net/quic/core/crypto/quic_encrypter.h"
|
| @@ -899,6 +900,57 @@ void CryptoTestUtils::MovePackets(PacketSavingConnection* source_conn,
|
| QuicConnectionPeer::SetCurrentPacket(dest_conn, StringPiece(nullptr, 0));
|
| }
|
|
|
| +CryptoHandshakeMessage CryptoTestUtils::GenerateDefaultInchoateCHLO(
|
| + const QuicClock* clock,
|
| + QuicVersion version,
|
| + QuicCryptoServerConfig* crypto_config) {
|
| + // clang-format off
|
| + return CryptoTestUtils::Message(
|
| + "CHLO",
|
| + "PDMD", "X509",
|
| + "AEAD", "AESG",
|
| + "KEXS", "C255",
|
| + "PUBS", CryptoTestUtils::GenerateClientPublicValuesHex().c_str(),
|
| + "NONC", CryptoTestUtils::GenerateClientNonceHex(clock,
|
| + crypto_config).c_str(),
|
| + "VER\0", QuicUtils::TagToString(
|
| + QuicVersionToQuicTag(version)).c_str(),
|
| + "$padding", static_cast<int>(kClientHelloMinimumSize),
|
| + nullptr);
|
| + // clang-format on
|
| +}
|
| +
|
| +string CryptoTestUtils::GenerateClientNonceHex(
|
| + const QuicClock* clock,
|
| + QuicCryptoServerConfig* crypto_config) {
|
| + net::QuicCryptoServerConfig::ConfigOptions old_config_options;
|
| + net::QuicCryptoServerConfig::ConfigOptions new_config_options;
|
| + old_config_options.id = "old-config-id";
|
| + delete crypto_config->AddDefaultConfig(net::QuicRandom::GetInstance(), clock,
|
| + old_config_options);
|
| + std::unique_ptr<QuicServerConfigProtobuf> primary_config(
|
| + crypto_config->GenerateConfig(net::QuicRandom::GetInstance(), clock,
|
| + new_config_options));
|
| + primary_config->set_primary_time(clock->WallNow().ToUNIXSeconds());
|
| + std::unique_ptr<net::CryptoHandshakeMessage> msg(
|
| + crypto_config->AddConfig(primary_config.get(), clock->WallNow()));
|
| + StringPiece orbit;
|
| + CHECK(msg->GetStringPiece(net::kORBT, &orbit));
|
| + string nonce;
|
| + net::CryptoUtils::GenerateNonce(
|
| + clock->WallNow(), net::QuicRandom::GetInstance(),
|
| + StringPiece(reinterpret_cast<const char*>(orbit.data()),
|
| + sizeof(orbit.size())),
|
| + &nonce);
|
| + return ("#" + net::QuicUtils::HexEncode(nonce));
|
| +}
|
| +
|
| +string CryptoTestUtils::GenerateClientPublicValuesHex() {
|
| + char public_value[32];
|
| + memset(public_value, 42, sizeof(public_value));
|
| + return ("#" + net::QuicUtils::HexEncode(public_value, sizeof(public_value)));
|
| +}
|
| +
|
| // static
|
| void CryptoTestUtils::GenerateFullCHLO(
|
| const CryptoHandshakeMessage& inchoate_chlo,
|
|
|