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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "net/base/net_errors.h" | 6 #include "net/base/net_errors.h" |
7 #include "net/base/test_completion_callback.h" | 7 #include "net/base/test_completion_callback.h" |
8 #include "net/base/test_data_directory.h" | 8 #include "net/base/test_data_directory.h" |
9 #include "net/cert/x509_certificate.h" | 9 #include "net/cert/x509_certificate.h" |
10 #include "net/quic/crypto/proof_source.h" | 10 #include "net/quic/crypto/proof_source.h" |
11 #include "net/quic/crypto/proof_verifier.h" | 11 #include "net/quic/crypto/proof_verifier.h" |
12 #include "net/quic/test_tools/crypto_test_utils.h" | 12 #include "net/quic/test_tools/crypto_test_utils.h" |
13 #include "net/test/cert_test_util.h" | 13 #include "net/test/cert_test_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 #if defined(OS_WIN) | |
17 #include "base/win/windows_version.h" | |
18 #endif | |
19 | |
20 using std::string; | 16 using std::string; |
21 using std::vector; | 17 using std::vector; |
22 | 18 |
23 namespace net { | 19 namespace net { |
24 namespace test { | 20 namespace test { |
25 | 21 |
26 TEST(Proof, Verify) { | 22 TEST(Proof, Verify) { |
27 // TODO(rtenneti): Enable testing of ProofVerifier. | 23 // TODO(rtenneti): Enable testing of ProofVerifier. |
28 #if 0 | 24 #if 0 |
29 scoped_ptr<ProofSource> source(CryptoTestUtils::ProofSourceForTesting()); | 25 scoped_ptr<ProofSource> source(CryptoTestUtils::ProofSourceForTesting()); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 rv = verifier->VerifyProof("foo.com", server_config, wrong_certs, signature, | 253 rv = verifier->VerifyProof("foo.com", server_config, wrong_certs, signature, |
258 &error_details, callback.callback()); | 254 &error_details, callback.callback()); |
259 rv = callback.GetResult(rv); | 255 rv = callback.GetResult(rv); |
260 ASSERT_EQ(ERR_FAILED, rv); | 256 ASSERT_EQ(ERR_FAILED, rv); |
261 ASSERT_NE("", error_details); | 257 ASSERT_NE("", error_details); |
262 } | 258 } |
263 } | 259 } |
264 | 260 |
265 // A known answer test that allows us to test ProofVerifier without a working | 261 // A known answer test that allows us to test ProofVerifier without a working |
266 // ProofSource. | 262 // ProofSource. |
267 // TODO(rtenneti): Enable VerifyECDSAKnownAnswerTest on win_rel and XP. | 263 // TODO(rtenneti): Enable VerifyECDSAKnownAnswerTest on Windows. Disabled this |
| 264 // test because X509Certificate::GetPublicKeyInfo is not returning the correct |
| 265 // type for ECDSA certificates. |
268 #if defined(OS_WIN) | 266 #if defined(OS_WIN) |
269 #define MAYBE_VerifyECDSAKnownAnswerTest DISABLED_VerifyECDSAKnownAnswerTest | 267 #define MAYBE_VerifyECDSAKnownAnswerTest DISABLED_VerifyECDSAKnownAnswerTest |
270 #else | 268 #else |
271 #define MAYBE_VerifyECDSAKnownAnswerTest VerifyECDSAKnownAnswerTest | 269 #define MAYBE_VerifyECDSAKnownAnswerTest VerifyECDSAKnownAnswerTest |
272 #endif | 270 #endif |
273 TEST(Proof, MAYBE_VerifyECDSAKnownAnswerTest) { | 271 TEST(Proof, MAYBE_VerifyECDSAKnownAnswerTest) { |
274 // These sample signatures were generated by running the Proof.Verify test | 272 // These sample signatures were generated by running the Proof.Verify test |
275 // (modified to use ECDSA for signing proofs) and dumping the bytes of the | 273 // (modified to use ECDSA for signing proofs) and dumping the bytes of the |
276 // |signature| output of ProofSource::GetProof(). | 274 // |signature| output of ProofSource::GetProof(). |
277 static const unsigned char signature_data_0[] = { | 275 static const unsigned char signature_data_0[] = { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 rv = verifier->VerifyProof("foo.com", server_config, wrong_certs, signature, | 373 rv = verifier->VerifyProof("foo.com", server_config, wrong_certs, signature, |
376 &error_details, callback.callback()); | 374 &error_details, callback.callback()); |
377 rv = callback.GetResult(rv); | 375 rv = callback.GetResult(rv); |
378 ASSERT_EQ(ERR_FAILED, rv); | 376 ASSERT_EQ(ERR_FAILED, rv); |
379 ASSERT_NE("", error_details); | 377 ASSERT_NE("", error_details); |
380 } | 378 } |
381 } | 379 } |
382 | 380 |
383 } // namespace test | 381 } // namespace test |
384 } // namespace net | 382 } // namespace net |
OLD | NEW |