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

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

Issue 2463093003: Landing Recent QUIC changes until Sat Oct 29 14:59:35. (Closed)
Patch Set: add change to quiartc_session_test.cc Created 4 years, 1 month 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/test_tools/crypto_test_utils.h ('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 <memory> 7 #include <memory>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "crypto/openssl_util.h" 10 #include "crypto/openssl_util.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 323 }
324 324
325 class ProcessClientHelloCallback : public ProcessClientHelloResultCallback { 325 class ProcessClientHelloCallback : public ProcessClientHelloResultCallback {
326 public: 326 public:
327 explicit ProcessClientHelloCallback(FullChloGenerator* generator) 327 explicit ProcessClientHelloCallback(FullChloGenerator* generator)
328 : generator_(generator) {} 328 : generator_(generator) {}
329 void Run( 329 void Run(
330 QuicErrorCode error, 330 QuicErrorCode error,
331 const string& error_details, 331 const string& error_details,
332 std::unique_ptr<CryptoHandshakeMessage> message, 332 std::unique_ptr<CryptoHandshakeMessage> message,
333 std::unique_ptr<DiversificationNonce> diversification_nonce) override { 333 std::unique_ptr<DiversificationNonce> diversification_nonce,
334 std::unique_ptr<ProofSource::Details> proof_source_details) override {
334 generator_->ProcessClientHelloDone(std::move(message)); 335 generator_->ProcessClientHelloDone(std::move(message));
335 } 336 }
336 337
337 private: 338 private:
338 FullChloGenerator* generator_; 339 FullChloGenerator* generator_;
339 }; 340 };
340 341
341 std::unique_ptr<ProcessClientHelloCallback> GetProcessClientHelloCallback() { 342 std::unique_ptr<ProcessClientHelloCallback> GetProcessClientHelloCallback() {
342 return std::unique_ptr<ProcessClientHelloCallback>( 343 return std::unique_ptr<ProcessClientHelloCallback>(
343 new ProcessClientHelloCallback(this)); 344 new ProcessClientHelloCallback(this));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_SERVER, 395 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_SERVER,
395 client_conn->supported_versions()); 396 client_conn->supported_versions());
396 397
397 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, 398 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING,
398 QuicRandom::GetInstance(), 399 QuicRandom::GetInstance(),
399 ProofSourceForTesting()); 400 ProofSourceForTesting());
400 QuicCompressedCertsCache compressed_certs_cache( 401 QuicCompressedCertsCache compressed_certs_cache(
401 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize); 402 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize);
402 SetupCryptoServerConfigForTest(server_conn->clock(), 403 SetupCryptoServerConfigForTest(server_conn->clock(),
403 server_conn->random_generator(), 404 server_conn->random_generator(),
404 server_quic_config, &crypto_config, options); 405 &crypto_config, options);
405 406
406 TestQuicSpdyServerSession server_session(server_conn, *server_quic_config, 407 TestQuicSpdyServerSession server_session(server_conn, *server_quic_config,
407 &crypto_config, 408 &crypto_config,
408 &compressed_certs_cache); 409 &compressed_certs_cache);
409 410
410 // The client's handshake must have been started already. 411 // The client's handshake must have been started already.
411 CHECK_NE(0u, client_conn->encrypted_packets_.size()); 412 CHECK_NE(0u, client_conn->encrypted_packets_.size());
412 413
413 CommunicateHandshakeMessages(client_conn, client, server_conn, 414 CommunicateHandshakeMessages(client_conn, client, server_conn,
414 server_session.GetCryptoStream()); 415 server_session.GetCryptoStream());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 473 }
473 } 474 }
474 475
475 return client_session.GetCryptoStream()->num_sent_client_hellos(); 476 return client_session.GetCryptoStream()->num_sent_client_hellos();
476 } 477 }
477 478
478 // static 479 // static
479 void CryptoTestUtils::SetupCryptoServerConfigForTest( 480 void CryptoTestUtils::SetupCryptoServerConfigForTest(
480 const QuicClock* clock, 481 const QuicClock* clock,
481 QuicRandom* rand, 482 QuicRandom* rand,
482 QuicConfig* config,
483 QuicCryptoServerConfig* crypto_config, 483 QuicCryptoServerConfig* crypto_config,
484 const FakeServerOptions& fake_options) { 484 const FakeServerOptions& fake_options) {
485 QuicCryptoServerConfig::ConfigOptions options; 485 QuicCryptoServerConfig::ConfigOptions options;
486 options.channel_id_enabled = true; 486 options.channel_id_enabled = true;
487 options.token_binding_params = fake_options.token_binding_params; 487 options.token_binding_params = fake_options.token_binding_params;
488 std::unique_ptr<CryptoHandshakeMessage> scfg( 488 std::unique_ptr<CryptoHandshakeMessage> scfg(
489 crypto_config->AddDefaultConfig(rand, clock, options)); 489 crypto_config->AddDefaultConfig(rand, clock, options));
490 } 490 }
491 491
492 // static 492 // static
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 565 }
566 566
567 uint64_t CryptoTestUtils::LeafCertHashForTesting() { 567 uint64_t CryptoTestUtils::LeafCertHashForTesting() {
568 scoped_refptr<ProofSource::Chain> chain; 568 scoped_refptr<ProofSource::Chain> chain;
569 IPAddress server_ip; 569 IPAddress server_ip;
570 string sig; 570 string sig;
571 string cert_sct; 571 string cert_sct;
572 std::unique_ptr<ProofSource> proof_source( 572 std::unique_ptr<ProofSource> proof_source(
573 CryptoTestUtils::ProofSourceForTesting()); 573 CryptoTestUtils::ProofSourceForTesting());
574 if (!proof_source->GetProof(server_ip, "", "", AllSupportedVersions().front(), 574 if (!proof_source->GetProof(server_ip, "", "", AllSupportedVersions().front(),
575 "", &chain, &sig, &cert_sct) || 575 "", QuicTagVector(), &chain, &sig, &cert_sct) ||
576 chain->certs.empty()) { 576 chain->certs.empty()) {
577 DCHECK(false) << "Proof generation failed"; 577 DCHECK(false) << "Proof generation failed";
578 return 0; 578 return 0;
579 } 579 }
580 580
581 return QuicUtils::FNV1a_64_Hash(chain->certs.at(0).c_str(), 581 return QuicUtils::FNV1a_64_Hash(chain->certs.at(0).c_str(),
582 chain->certs.at(0).length()); 582 chain->certs.at(0).length());
583 } 583 }
584 584
585 class MockCommonCertSets : public CommonCertSets { 585 class MockCommonCertSets : public CommonCertSets {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 // Pass a inchoate CHLO. 1012 // Pass a inchoate CHLO.
1013 FullChloGenerator generator(crypto_config, server_ip, client_addr, clock, 1013 FullChloGenerator generator(crypto_config, server_ip, client_addr, clock,
1014 proof, compressed_certs_cache, out); 1014 proof, compressed_certs_cache, out);
1015 crypto_config->ValidateClientHello( 1015 crypto_config->ValidateClientHello(
1016 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, 1016 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof,
1017 generator.GetValidateClientHelloCallback()); 1017 generator.GetValidateClientHelloCallback());
1018 } 1018 }
1019 1019
1020 } // namespace test 1020 } // namespace test
1021 } // namespace net 1021 } // namespace net
OLDNEW
« 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