Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Unified Diff: net/quic/test_tools/crypto_test_utils.cc

Issue 2222393002: Make QuicDispatcher to queue packets for new connections while waiting for CHLOs. Flag protected by… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129318081
Patch Set: add new files Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/quic_buffered_packet_store_peer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/quic_buffered_packet_store_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698