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

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

Issue 2236973002: Landing Recent QUIC changes until 4AM, Aug 7, 2016 UTC-4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flip quic_sequencer_buffer_retire_block_in_time to true 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/crypto_test_utils_test.cc » ('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 f285e254e9f568f20144a01b0dfb47cdb5b8a1c6..8b0cf604cae7cb3aea172282a16ed560b68d2c76 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"
@@ -299,10 +300,11 @@ class FullChloGenerator : public ValidateClientHelloResultCallback {
CryptoHandshakeMessage rej;
crypto_config_->ProcessClientHello(
result, /*reject_only=*/false, /*connection_id=*/1, server_ip_,
- client_addr_, QuicSupportedVersions().front(), QuicSupportedVersions(),
+ client_addr_, AllSupportedVersions().front(), AllSupportedVersions(),
/*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0,
clock_, QuicRandom::GetInstance(), compressed_certs_cache_, &params,
- proof_, &rej, &diversification_nonce, &error_details);
+ proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej,
+ &diversification_nonce, &error_details);
// Verify output is a REJ or SREJ.
EXPECT_THAT(rej.tag(),
testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ)));
@@ -523,9 +525,8 @@ uint64_t CryptoTestUtils::LeafCertHashForTesting() {
string cert_sct;
std::unique_ptr<ProofSource> proof_source(
CryptoTestUtils::ProofSourceForTesting());
- if (!proof_source->GetProof(server_ip, "", "",
- QuicSupportedVersions().front(), "", &chain, &sig,
- &cert_sct) ||
+ if (!proof_source->GetProof(server_ip, "", "", AllSupportedVersions().front(),
+ "", &chain, &sig, &cert_sct) ||
chain->certs.empty()) {
DCHECK(false) << "Proof generation failed";
return 0;
@@ -883,6 +884,8 @@ void CryptoTestUtils::MovePackets(PacketSavingConnection* source_conn,
StringPiece(stream_frame->data_buffer, stream_frame->data_length)));
ASSERT_FALSE(crypto_visitor.error());
}
+ QuicConnectionPeer::SetCurrentPacket(
+ dest_conn, source_conn->encrypted_packets_[index]->AsStringPiece());
}
*inout_packet_index = index;
@@ -893,6 +896,58 @@ void CryptoTestUtils::MovePackets(PacketSavingConnection* source_conn,
for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) {
dest_stream->OnHandshakeMessage(message);
}
+ 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
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/crypto_test_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698