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

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

Issue 1421853006: Landing Recent QUIC changes until: Fri Oct 30 22:23:58 2015 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 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.cc ('k') | net/quic/test_tools/quic_connection_peer.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "net/quic/test_tools/crypto_test_utils.h" 5 #include "net/quic/test_tools/crypto_test_utils.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/test_data_directory.h" 10 #include "net/base/test_data_directory.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 private: 44 private:
45 ScopedTestRoot scoped_root_; 45 ScopedTestRoot scoped_root_;
46 scoped_ptr<CertVerifier> cert_verifier_; 46 scoped_ptr<CertVerifier> cert_verifier_;
47 scoped_ptr<TransportSecurityState> transport_security_state_; 47 scoped_ptr<TransportSecurityState> transport_security_state_;
48 }; 48 };
49 49
50 const char kLeafCert[] = "leaf"; 50 const char kLeafCert[] = "leaf";
51 const char kIntermediateCert[] = "intermediate"; 51 const char kIntermediateCert[] = "intermediate";
52 const char kSignature[] = "signature"; 52 const char kSignature[] = "signature";
53 const char kSCT[] = "CryptoServerTests";
53 54
54 class FakeProofSource : public ProofSource { 55 class FakeProofSource : public ProofSource {
55 public: 56 public:
56 FakeProofSource() : certs_(2) { 57 FakeProofSource() : certs_(2) {
57 certs_[0] = kLeafCert; 58 certs_[0] = kLeafCert;
58 certs_[1] = kIntermediateCert; 59 certs_[1] = kIntermediateCert;
59 } 60 }
60 ~FakeProofSource() override {} 61 ~FakeProofSource() override {}
61 62
62 // ProofSource interface 63 // ProofSource interface
63 bool GetProof(const IPAddressNumber& server_ip, 64 bool GetProof(const IPAddressNumber& server_ip,
64 const std::string& hostname, 65 const std::string& hostname,
65 const std::string& server_config, 66 const std::string& server_config,
66 bool ecdsa_ok, 67 bool ecdsa_ok,
67 const std::vector<std::string>** out_certs, 68 const std::vector<std::string>** out_certs,
68 std::string* out_signature) override { 69 std::string* out_signature,
70 std::string* out_leaf_cert_sct) override {
69 *out_certs = &certs_; 71 *out_certs = &certs_;
70 *out_signature = kSignature; 72 *out_signature = kSignature;
73 *out_leaf_cert_sct = kSCT;
71 return true; 74 return true;
72 } 75 }
73 76
74 private: 77 private:
75 std::vector<std::string> certs_; 78 std::vector<std::string> certs_;
76 DISALLOW_COPY_AND_ASSIGN(FakeProofSource); 79 DISALLOW_COPY_AND_ASSIGN(FakeProofSource);
77 }; 80 };
78 81
79 class FakeProofVerifier : public ProofVerifier { 82 class FakeProofVerifier : public ProofVerifier {
80 public: 83 public:
(...skipping 29 matching lines...) Expand all
110 }; 113 };
111 114
112 } // namespace 115 } // namespace
113 116
114 // static 117 // static
115 ProofSource* CryptoTestUtils::ProofSourceForTesting() { 118 ProofSource* CryptoTestUtils::ProofSourceForTesting() {
116 ProofSourceChromium* source = new ProofSourceChromium(); 119 ProofSourceChromium* source = new ProofSourceChromium();
117 base::FilePath certs_dir = GetTestCertsDirectory(); 120 base::FilePath certs_dir = GetTestCertsDirectory();
118 CHECK(source->Initialize( 121 CHECK(source->Initialize(
119 certs_dir.AppendASCII("quic_test.example.com.crt"), 122 certs_dir.AppendASCII("quic_test.example.com.crt"),
120 certs_dir.AppendASCII("quic_test.example.com.key.pkcs8"))); 123 certs_dir.AppendASCII("quic_test.example.com.key.pkcs8"),
124 certs_dir.AppendASCII("quic_test.example.com.key.sct")));
121 return source; 125 return source;
122 } 126 }
123 127
124 // static 128 // static
125 ProofVerifier* CryptoTestUtils::ProofVerifierForTesting() { 129 ProofVerifier* CryptoTestUtils::ProofVerifierForTesting() {
126 // TODO(rch): use a real cert verifier? 130 // TODO(rch): use a real cert verifier?
127 scoped_ptr<MockCertVerifier> cert_verifier(new MockCertVerifier()); 131 scoped_ptr<MockCertVerifier> cert_verifier(new MockCertVerifier());
128 net::CertVerifyResult verify_result; 132 net::CertVerifyResult verify_result;
129 verify_result.verified_cert = 133 verify_result.verified_cert =
130 ImportCertFromFile(GetTestCertsDirectory(), "quic_test.example.com.crt"); 134 ImportCertFromFile(GetTestCertsDirectory(), "quic_test.example.com.crt");
(...skipping 24 matching lines...) Expand all
155 } 159 }
156 160
157 // static 161 // static
158 ProofVerifyContext* CryptoTestUtils::FakeProofVerifyContextForTesting() { 162 ProofVerifyContext* CryptoTestUtils::FakeProofVerifyContextForTesting() {
159 return nullptr; 163 return nullptr;
160 } 164 }
161 165
162 } // namespace test 166 } // namespace test
163 167
164 } // namespace net 168 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.cc ('k') | net/quic/test_tools/quic_connection_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698