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

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

Issue 1411063004: Remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enough! 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
OLDNEW
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 "net/quic/crypto/channel_id.h" 7 #include "net/quic/crypto/channel_id.h"
8 #include "net/quic/crypto/common_cert_set.h" 8 #include "net/quic/crypto/common_cert_set.h"
9 #include "net/quic/crypto/crypto_handshake.h" 9 #include "net/quic/crypto/crypto_handshake.h"
10 #include "net/quic/crypto/quic_crypto_server_config.h" 10 #include "net/quic/crypto/quic_crypto_server_config.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 private: 161 private:
162 scoped_ptr<ChannelIDSource> sync_source_; 162 scoped_ptr<ChannelIDSource> sync_source_;
163 scoped_ptr<ChannelIDSourceCallback> callback_; 163 scoped_ptr<ChannelIDSourceCallback> callback_;
164 scoped_ptr<ChannelIDKey> channel_id_key_; 164 scoped_ptr<ChannelIDKey> channel_id_key_;
165 }; 165 };
166 166
167 } // anonymous namespace 167 } // anonymous namespace
168 168
169 CryptoTestUtils::FakeClientOptions::FakeClientOptions() 169 CryptoTestUtils::FakeClientOptions::FakeClientOptions()
170 : dont_verify_certs(false), 170 : channel_id_enabled(false), channel_id_source_async(false) {}
171 channel_id_enabled(false),
172 channel_id_source_async(false) {
173 }
174 171
175 // static 172 // static
176 int CryptoTestUtils::HandshakeWithFakeServer( 173 int CryptoTestUtils::HandshakeWithFakeServer(
177 MockHelper* helper, 174 MockHelper* helper,
178 PacketSavingConnection* client_conn, 175 PacketSavingConnection* client_conn,
179 QuicCryptoClientStream* client) { 176 QuicCryptoClientStream* client) {
180 PacketSavingConnection* server_conn = new PacketSavingConnection( 177 PacketSavingConnection* server_conn = new PacketSavingConnection(
181 helper, Perspective::IS_SERVER, client_conn->supported_versions()); 178 helper, Perspective::IS_SERVER, client_conn->supported_versions());
182 179
183 QuicConfig config = DefaultQuicConfig(); 180 QuicConfig config = DefaultQuicConfig();
184 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, 181 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING,
185 QuicRandom::GetInstance()); 182 QuicRandom::GetInstance(),
183 ProofSourceForTesting());
186 SetupCryptoServerConfigForTest(server_conn->clock(), 184 SetupCryptoServerConfigForTest(server_conn->clock(),
187 server_conn->random_generator(), &config, 185 server_conn->random_generator(), &config,
188 &crypto_config); 186 &crypto_config);
189 187
190 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config); 188 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config);
191 189
192 // The client's handshake must have been started already. 190 // The client's handshake must have been started already.
193 CHECK_NE(0u, client_conn->encrypted_packets_.size()); 191 CHECK_NE(0u, client_conn->encrypted_packets_.size());
194 192
195 CommunicateHandshakeMessages(client_conn, client, server_conn, 193 CommunicateHandshakeMessages(client_conn, client, server_conn,
196 server_session.GetCryptoStream()); 194 server_session.GetCryptoStream());
197
198 CompareClientAndServerKeys(client, server_session.GetCryptoStream()); 195 CompareClientAndServerKeys(client, server_session.GetCryptoStream());
199 196
200 return client->num_sent_client_hellos(); 197 return client->num_sent_client_hellos();
201 } 198 }
202 199
203 // static 200 // static
204 int CryptoTestUtils::HandshakeWithFakeClient( 201 int CryptoTestUtils::HandshakeWithFakeClient(
205 MockHelper* helper, 202 MockHelper* helper,
206 PacketSavingConnection* server_conn, 203 PacketSavingConnection* server_conn,
207 QuicCryptoServerStream* server, 204 QuicCryptoServerStream* server,
208 const QuicServerId& server_id, 205 const QuicServerId& server_id,
209 const FakeClientOptions& options) { 206 const FakeClientOptions& options) {
210 PacketSavingConnection* client_conn = 207 PacketSavingConnection* client_conn =
211 new PacketSavingConnection(helper, Perspective::IS_CLIENT); 208 new PacketSavingConnection(helper, Perspective::IS_CLIENT);
212 // Advance the time, because timers do not like uninitialized times. 209 // Advance the time, because timers do not like uninitialized times.
213 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 210 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1));
214 211
215 QuicCryptoClientConfig crypto_config; 212 QuicCryptoClientConfig crypto_config(ProofVerifierForTesting());
216 AsyncTestChannelIDSource* async_channel_id_source = nullptr; 213 AsyncTestChannelIDSource* async_channel_id_source = nullptr;
217 if (options.channel_id_enabled) { 214 if (options.channel_id_enabled) {
218 215
219 ChannelIDSource* source = ChannelIDSourceForTesting(); 216 ChannelIDSource* source = ChannelIDSourceForTesting();
220 if (options.channel_id_source_async) { 217 if (options.channel_id_source_async) {
221 async_channel_id_source = new AsyncTestChannelIDSource(source); 218 async_channel_id_source = new AsyncTestChannelIDSource(source);
222 source = async_channel_id_source; 219 source = async_channel_id_source;
223 } 220 }
224 crypto_config.SetChannelIDSource(source); 221 crypto_config.SetChannelIDSource(source);
225 } 222 }
226 if (!options.dont_verify_certs && server_id.is_https()) {
227 #if defined(USE_OPENSSL)
228 crypto_config.SetProofVerifier(ProofVerifierForTesting());
229 #else
230 // TODO(rch): Implement a NSS proof source.
231 crypto_config.SetProofVerifier(FakeProofVerifierForTesting());
232 #endif
233 }
234 TestQuicSpdyClientSession client_session(client_conn, DefaultQuicConfig(), 223 TestQuicSpdyClientSession client_session(client_conn, DefaultQuicConfig(),
235 server_id, &crypto_config); 224 server_id, &crypto_config);
236 225
237 client_session.GetCryptoStream()->CryptoConnect(); 226 client_session.GetCryptoStream()->CryptoConnect();
238 CHECK_EQ(1u, client_conn->encrypted_packets_.size()); 227 CHECK_EQ(1u, client_conn->encrypted_packets_.size());
239 228
240 CommunicateHandshakeMessagesAndRunCallbacks( 229 CommunicateHandshakeMessagesAndRunCallbacks(
241 client_conn, client_session.GetCryptoStream(), server_conn, server, 230 client_conn, client_session.GetCryptoStream(), server_conn, server,
242 async_channel_id_source); 231 async_channel_id_source);
243 232
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 scoped_ptr<CryptoHandshakeMessage> parsed( 603 scoped_ptr<CryptoHandshakeMessage> parsed(
615 CryptoFramer::ParseMessage(bytes->AsStringPiece())); 604 CryptoFramer::ParseMessage(bytes->AsStringPiece()));
616 CHECK(parsed.get()); 605 CHECK(parsed.get());
617 606
618 va_end(ap); 607 va_end(ap);
619 return *parsed; 608 return *parsed;
620 } 609 }
621 610
622 } // namespace test 611 } // namespace test
623 } // namespace net 612 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/quic_chromium_client_session_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698