OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "net/base/ip_endpoint.h" | 8 #include "net/base/ip_endpoint.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
11 #include "net/base/test_data_directory.h" | 11 #include "net/base/test_data_directory.h" |
12 #include "net/cert/cert_status_flags.h" | 12 #include "net/cert/cert_status_flags.h" |
13 #include "net/cert/cert_verify_result.h" | 13 #include "net/cert/cert_verify_result.h" |
14 #include "net/cert/x509_certificate.h" | 14 #include "net/cert/x509_certificate.h" |
15 #include "net/quic/crypto/proof_source.h" | 15 #include "net/quic/crypto/proof_source.h" |
16 #include "net/quic/crypto/proof_verifier.h" | 16 #include "net/quic/crypto/proof_verifier.h" |
17 #include "net/quic/test_tools/crypto_test_utils.h" | 17 #include "net/quic/test_tools/crypto_test_utils.h" |
18 #include "net/test/cert_test_util.h" | 18 #include "net/test/cert_test_util.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 #if defined(OS_WIN) | |
22 #include "base/win/windows_version.h" | |
23 #endif | |
24 | |
25 using std::string; | 21 using std::string; |
26 using std::vector; | 22 using std::vector; |
27 | 23 |
28 namespace net { | 24 namespace net { |
29 namespace test { | 25 namespace test { |
30 namespace { | 26 namespace { |
31 | 27 |
32 // TestProofVerifierCallback is a simple callback for a ProofVerifier that | 28 // TestProofVerifierCallback is a simple callback for a ProofVerifier that |
33 // signals a TestCompletionCallback when called and stores the results from the | 29 // signals a TestCompletionCallback when called and stores the results from the |
34 // ProofVerifier in pointers passed to the constructor. | 30 // ProofVerifier in pointers passed to the constructor. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 chlo_hash, wrong_certs, signature, false); | 323 chlo_hash, wrong_certs, signature, false); |
328 } | 324 } |
329 } | 325 } |
330 | 326 |
331 // A known answer test that allows us to test ProofVerifier without a working | 327 // A known answer test that allows us to test ProofVerifier without a working |
332 // ProofSource. | 328 // ProofSource. |
333 TEST_P(ProofTest, VerifyECDSAKnownAnswerTest) { | 329 TEST_P(ProofTest, VerifyECDSAKnownAnswerTest) { |
334 if (GetParam() > QUIC_VERSION_30) { | 330 if (GetParam() > QUIC_VERSION_30) { |
335 return; | 331 return; |
336 } | 332 } |
337 // These sample signatures were generated by running the Proof.Verify test | |
338 // (modified to use ECDSA for signing proofs) and dumping the bytes of the | |
339 // |signature| output of ProofSource::GetProof(). | |
340 | |
341 // Disable this test on platforms that do not support ECDSA certificates. | |
342 #if defined(OS_WIN) | |
343 if (base::win::GetVersion() < base::win::VERSION_VISTA) | |
344 return; | |
345 #endif | |
346 | 333 |
347 // These sample signatures were generated by running the Proof.Verify test | 334 // These sample signatures were generated by running the Proof.Verify test |
348 // (modified to use ECDSA for signing proofs) and dumping the bytes of the | 335 // (modified to use ECDSA for signing proofs) and dumping the bytes of the |
349 // |signature| output of ProofSource::GetProof(). | 336 // |signature| output of ProofSource::GetProof(). |
350 static const unsigned char signature_data_0[] = { | 337 static const unsigned char signature_data_0[] = { |
351 0x30, 0x45, 0x02, 0x21, 0x00, 0x89, 0xc4, 0x7d, 0x08, 0xd1, 0x49, 0x19, | 338 0x30, 0x45, 0x02, 0x21, 0x00, 0x89, 0xc4, 0x7d, 0x08, 0xd1, 0x49, 0x19, |
352 0x6c, 0xd1, 0x7c, 0xb9, 0x25, 0xe0, 0xe3, 0xbd, 0x6a, 0x5c, 0xd7, 0xaa, | 339 0x6c, 0xd1, 0x7c, 0xb9, 0x25, 0xe0, 0xe3, 0xbd, 0x6a, 0x5c, 0xd7, 0xaa, |
353 0x0c, 0xdc, 0x4f, 0x8e, 0xeb, 0xde, 0xbf, 0x32, 0xf8, 0xd1, 0x84, 0x95, | 340 0x0c, 0xdc, 0x4f, 0x8e, 0xeb, 0xde, 0xbf, 0x32, 0xf8, 0xd1, 0x84, 0x95, |
354 0x97, 0x02, 0x20, 0x29, 0x3d, 0x49, 0x22, 0x73, 0xed, 0x8b, 0xde, 0x3d, | 341 0x97, 0x02, 0x20, 0x29, 0x3d, 0x49, 0x22, 0x73, 0xed, 0x8b, 0xde, 0x3d, |
355 0xc2, 0xa4, 0x20, 0xcc, 0xe7, 0xc8, 0x2a, 0x85, 0x20, 0x9b, 0x5b, 0xda, | 342 0xc2, 0xa4, 0x20, 0xcc, 0xe7, 0xc8, 0x2a, 0x85, 0x20, 0x9b, 0x5b, 0xda, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 for (size_t i = 1; i < certs.size(); i++) { | 409 for (size_t i = 1; i < certs.size(); i++) { |
423 wrong_certs.push_back(certs[i]); | 410 wrong_certs.push_back(certs[i]); |
424 } | 411 } |
425 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | 412 RunVerification(verifier.get(), hostname, port, server_config, quic_version, |
426 chlo_hash, wrong_certs, signature, false); | 413 chlo_hash, wrong_certs, signature, false); |
427 } | 414 } |
428 } | 415 } |
429 | 416 |
430 } // namespace test | 417 } // namespace test |
431 } // namespace net | 418 } // namespace net |
OLD | NEW |