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

Side by Side Diff: net/quic/test_tools/crypto_test_utils.cc

Issue 2227553003: Use the CHLO packet size, not message size when determining how large a REJ can be. Protected by --… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129101660
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_flags.cc ('k') | net/quic/test_tools/crypto_test_utils_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/test_tools/crypto_test_utils.h" 5 #include "net/quic/test_tools/crypto_test_utils.h"
6 6
7 #include <openssl/bn.h> 7 #include <openssl/bn.h>
8 #include <openssl/ec.h> 8 #include <openssl/ec.h>
9 #include <openssl/ecdsa.h> 9 #include <openssl/ecdsa.h>
10 #include <openssl/evp.h> 10 #include <openssl/evp.h>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 std::unique_ptr<ProofSource::Details> /* details */) override { 295 std::unique_ptr<ProofSource::Details> /* details */) override {
296 QuicCryptoNegotiatedParameters params; 296 QuicCryptoNegotiatedParameters params;
297 string error_details; 297 string error_details;
298 DiversificationNonce diversification_nonce; 298 DiversificationNonce diversification_nonce;
299 CryptoHandshakeMessage rej; 299 CryptoHandshakeMessage rej;
300 crypto_config_->ProcessClientHello( 300 crypto_config_->ProcessClientHello(
301 result, /*reject_only=*/false, /*connection_id=*/1, server_ip_, 301 result, /*reject_only=*/false, /*connection_id=*/1, server_ip_,
302 client_addr_, QuicSupportedVersions().front(), QuicSupportedVersions(), 302 client_addr_, QuicSupportedVersions().front(), QuicSupportedVersions(),
303 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0, 303 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0,
304 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, &params, 304 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, &params,
305 proof_, &rej, &diversification_nonce, &error_details); 305 proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej,
306 &diversification_nonce, &error_details);
306 // Verify output is a REJ or SREJ. 307 // Verify output is a REJ or SREJ.
307 EXPECT_THAT(rej.tag(), 308 EXPECT_THAT(rej.tag(),
308 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ))); 309 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ)));
309 310
310 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString(); 311 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString();
311 StringPiece srct; 312 StringPiece srct;
312 ASSERT_TRUE(rej.GetStringPiece(kSourceAddressTokenTag, &srct)); 313 ASSERT_TRUE(rej.GetStringPiece(kSourceAddressTokenTag, &srct));
313 314
314 StringPiece scfg; 315 StringPiece scfg;
315 ASSERT_TRUE(rej.GetStringPiece(kSCFG, &scfg)); 316 ASSERT_TRUE(rej.GetStringPiece(kSCFG, &scfg));
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // The framer will be unable to decrypt forward-secure packets sent after 877 // The framer will be unable to decrypt forward-secure packets sent after
877 // the handshake is complete. Don't treat them as handshake packets. 878 // the handshake is complete. Don't treat them as handshake packets.
878 break; 879 break;
879 } 880 }
880 881
881 for (const QuicStreamFrame* stream_frame : framer.stream_frames()) { 882 for (const QuicStreamFrame* stream_frame : framer.stream_frames()) {
882 ASSERT_TRUE(crypto_framer.ProcessInput( 883 ASSERT_TRUE(crypto_framer.ProcessInput(
883 StringPiece(stream_frame->data_buffer, stream_frame->data_length))); 884 StringPiece(stream_frame->data_buffer, stream_frame->data_length)));
884 ASSERT_FALSE(crypto_visitor.error()); 885 ASSERT_FALSE(crypto_visitor.error());
885 } 886 }
887 QuicConnectionPeer::SetCurrentPacket(
888 dest_conn, source_conn->encrypted_packets_[index]->AsStringPiece());
886 } 889 }
887 *inout_packet_index = index; 890 *inout_packet_index = index;
888 891
889 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer()); 892 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer());
890 893
891 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining()); 894 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining());
892 895
893 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) { 896 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) {
894 dest_stream->OnHandshakeMessage(message); 897 dest_stream->OnHandshakeMessage(message);
895 } 898 }
899 QuicConnectionPeer::SetCurrentPacket(dest_conn, StringPiece(nullptr, 0));
896 } 900 }
897 901
898 // static 902 // static
899 void CryptoTestUtils::GenerateFullCHLO( 903 void CryptoTestUtils::GenerateFullCHLO(
900 const CryptoHandshakeMessage& inchoate_chlo, 904 const CryptoHandshakeMessage& inchoate_chlo,
901 QuicCryptoServerConfig* crypto_config, 905 QuicCryptoServerConfig* crypto_config,
902 IPAddress server_ip, 906 IPAddress server_ip,
903 IPEndPoint client_addr, 907 IPEndPoint client_addr,
904 QuicVersion version, 908 QuicVersion version,
905 const QuicClock* clock, 909 const QuicClock* clock,
906 QuicCryptoProof* proof, 910 QuicCryptoProof* proof,
907 QuicCompressedCertsCache* compressed_certs_cache, 911 QuicCompressedCertsCache* compressed_certs_cache,
908 CryptoHandshakeMessage* out) { 912 CryptoHandshakeMessage* out) {
909 // Pass a inchoate CHLO. 913 // Pass a inchoate CHLO.
910 crypto_config->ValidateClientHello( 914 crypto_config->ValidateClientHello(
911 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, 915 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof,
912 new FullChloGenerator(crypto_config, server_ip, client_addr, clock, proof, 916 new FullChloGenerator(crypto_config, server_ip, client_addr, clock, proof,
913 compressed_certs_cache, out)); 917 compressed_certs_cache, out));
914 } 918 }
915 919
916 } // namespace test 920 } // namespace test
917 } // namespace net 921 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_flags.cc ('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