| OLD | NEW |
| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 void RunImpl(const CryptoHandshakeMessage& client_hello, | 294 void RunImpl(const CryptoHandshakeMessage& client_hello, |
| 295 const ValidateClientHelloResultCallback::Result& result, | 295 const ValidateClientHelloResultCallback::Result& result, |
| 296 std::unique_ptr<ProofSource::Details> /* details */) override { | 296 std::unique_ptr<ProofSource::Details> /* details */) override { |
| 297 QuicCryptoNegotiatedParameters params; | 297 QuicCryptoNegotiatedParameters params; |
| 298 string error_details; | 298 string error_details; |
| 299 DiversificationNonce diversification_nonce; | 299 DiversificationNonce diversification_nonce; |
| 300 CryptoHandshakeMessage rej; | 300 CryptoHandshakeMessage rej; |
| 301 crypto_config_->ProcessClientHello( | 301 crypto_config_->ProcessClientHello( |
| 302 result, /*reject_only=*/false, /*connection_id=*/1, server_ip_, | 302 result, /*reject_only=*/false, /*connection_id=*/1, server_ip_, |
| 303 client_addr_, QuicSupportedVersions().front(), QuicSupportedVersions(), | 303 client_addr_, AllSupportedVersions().front(), AllSupportedVersions(), |
| 304 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0, | 304 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0, |
| 305 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, ¶ms, | 305 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, ¶ms, |
| 306 proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej, | 306 proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej, |
| 307 &diversification_nonce, &error_details); | 307 &diversification_nonce, &error_details); |
| 308 // Verify output is a REJ or SREJ. | 308 // Verify output is a REJ or SREJ. |
| 309 EXPECT_THAT(rej.tag(), | 309 EXPECT_THAT(rej.tag(), |
| 310 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ))); | 310 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ))); |
| 311 | 311 |
| 312 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString(); | 312 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString(); |
| 313 StringPiece srct; | 313 StringPiece srct; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 return it->second; | 518 return it->second; |
| 519 } | 519 } |
| 520 | 520 |
| 521 uint64_t CryptoTestUtils::LeafCertHashForTesting() { | 521 uint64_t CryptoTestUtils::LeafCertHashForTesting() { |
| 522 scoped_refptr<ProofSource::Chain> chain; | 522 scoped_refptr<ProofSource::Chain> chain; |
| 523 IPAddress server_ip; | 523 IPAddress server_ip; |
| 524 string sig; | 524 string sig; |
| 525 string cert_sct; | 525 string cert_sct; |
| 526 std::unique_ptr<ProofSource> proof_source( | 526 std::unique_ptr<ProofSource> proof_source( |
| 527 CryptoTestUtils::ProofSourceForTesting()); | 527 CryptoTestUtils::ProofSourceForTesting()); |
| 528 if (!proof_source->GetProof(server_ip, "", "", | 528 if (!proof_source->GetProof(server_ip, "", "", AllSupportedVersions().front(), |
| 529 QuicSupportedVersions().front(), "", &chain, &sig, | 529 "", &chain, &sig, &cert_sct) || |
| 530 &cert_sct) || | |
| 531 chain->certs.empty()) { | 530 chain->certs.empty()) { |
| 532 DCHECK(false) << "Proof generation failed"; | 531 DCHECK(false) << "Proof generation failed"; |
| 533 return 0; | 532 return 0; |
| 534 } | 533 } |
| 535 | 534 |
| 536 return QuicUtils::FNV1a_64_Hash(chain->certs.at(0).c_str(), | 535 return QuicUtils::FNV1a_64_Hash(chain->certs.at(0).c_str(), |
| 537 chain->certs.at(0).length()); | 536 chain->certs.at(0).length()); |
| 538 } | 537 } |
| 539 | 538 |
| 540 class MockCommonCertSets : public CommonCertSets { | 539 class MockCommonCertSets : public CommonCertSets { |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 CryptoHandshakeMessage* out) { | 963 CryptoHandshakeMessage* out) { |
| 965 // Pass a inchoate CHLO. | 964 // Pass a inchoate CHLO. |
| 966 crypto_config->ValidateClientHello( | 965 crypto_config->ValidateClientHello( |
| 967 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, | 966 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, |
| 968 new FullChloGenerator(crypto_config, server_ip, client_addr, clock, proof, | 967 new FullChloGenerator(crypto_config, server_ip, client_addr, clock, proof, |
| 969 compressed_certs_cache, out)); | 968 compressed_certs_cache, out)); |
| 970 } | 969 } |
| 971 | 970 |
| 972 } // namespace test | 971 } // namespace test |
| 973 } // namespace net | 972 } // namespace net |
| OLD | NEW |