| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/quic/crypto/proof_source.h" |
| 6 #include "net/quic/crypto/proof_verifier.h" |
| 7 #include "net/quic/test_tools/crypto_test_utils.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 using std::string; |
| 11 using std::vector; |
| 12 |
| 13 namespace net { |
| 14 namespace test { |
| 15 |
| 16 TEST(Proof, Verify) { |
| 17 // TODO(rtenneti): Enable testing of ProofVerifier. |
| 18 #if 0 |
| 19 scoped_ptr<ProofSource> source(CryptoTestUtils::ProofSourceForTesting()); |
| 20 scoped_ptr<ProofVerifier> verifier( |
| 21 CryptoTestUtils::ProofVerifierForTesting()); |
| 22 |
| 23 const string server_config = "server config bytes"; |
| 24 const string hostname = "test.example.com"; |
| 25 const vector<string>* certs; |
| 26 const vector<string>* first_certs; |
| 27 string error_details, signature, first_signature; |
| 28 |
| 29 ASSERT_TRUE(source->GetProof(hostname, server_config, &first_certs, |
| 30 &first_signature)); |
| 31 ASSERT_TRUE(source->GetProof(hostname, server_config, &certs, &signature)); |
| 32 |
| 33 // Check that the proof source is caching correctly: |
| 34 ASSERT_EQ(first_certs, certs); |
| 35 ASSERT_EQ(signature, first_signature); |
| 36 |
| 37 ASSERT_TRUE(verifier->VerifyProof(hostname, server_config, *certs, signature, |
| 38 &error_details)); |
| 39 ASSERT_FALSE(verifier->VerifyProof("foo.com", server_config, *certs, |
| 40 signature, &error_details)); |
| 41 ASSERT_FALSE( |
| 42 verifier->VerifyProof(hostname, server_config.substr(1, string::npos), |
| 43 *certs, signature, &error_details)); |
| 44 const string corrupt_signature = "1" + signature; |
| 45 ASSERT_FALSE(verifier->VerifyProof(hostname, server_config, *certs, |
| 46 corrupt_signature, &error_details)); |
| 47 |
| 48 vector<string> wrong_certs; |
| 49 for (size_t i = 1; i < certs->size(); i++) { |
| 50 wrong_certs.push_back((*certs)[i]); |
| 51 } |
| 52 ASSERT_FALSE(verifier->VerifyProof("foo.com", server_config, wrong_certs, |
| 53 signature, &error_details)); |
| 54 #endif // 0 |
| 55 } |
| 56 |
| 57 } // namespace test |
| 58 } // namespace net |
| OLD | NEW |