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

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: Created 5 years, 2 months 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),
171 channel_id_enabled(false),
172 channel_id_source_async(false) { 171 channel_id_source_async(false) {
173 } 172 }
174 173
175 // static 174 // static
176 int CryptoTestUtils::HandshakeWithFakeServer( 175 int CryptoTestUtils::HandshakeWithFakeServer(
177 MockHelper* helper, 176 MockHelper* helper,
178 PacketSavingConnection* client_conn, 177 PacketSavingConnection* client_conn,
179 QuicCryptoClientStream* client) { 178 QuicCryptoClientStream* client) {
180 PacketSavingConnection* server_conn = new PacketSavingConnection( 179 PacketSavingConnection* server_conn = new PacketSavingConnection(
181 helper, Perspective::IS_SERVER, client_conn->supported_versions()); 180 helper, Perspective::IS_SERVER, client_conn->supported_versions());
182 181
183 QuicConfig config = DefaultQuicConfig(); 182 QuicConfig config = DefaultQuicConfig();
184 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, 183 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING,
185 QuicRandom::GetInstance()); 184 QuicRandom::GetInstance(),
185 ProofSourceForTesting());
186 SetupCryptoServerConfigForTest(server_conn->clock(), 186 SetupCryptoServerConfigForTest(server_conn->clock(),
187 server_conn->random_generator(), &config, 187 server_conn->random_generator(), &config,
188 &crypto_config); 188 &crypto_config);
189 189
190 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config); 190 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config);
191 191
192 // The client's handshake must have been started already. 192 // The client's handshake must have been started already.
193 CHECK_NE(0u, client_conn->encrypted_packets_.size()); 193 CHECK_NE(0u, client_conn->encrypted_packets_.size());
194 194
195 CommunicateHandshakeMessages(client_conn, client, server_conn, 195 CommunicateHandshakeMessages(client_conn, client, server_conn,
196 server_session.GetCryptoStream()); 196 server_session.GetCryptoStream());
197
198 CompareClientAndServerKeys(client, server_session.GetCryptoStream()); 197 CompareClientAndServerKeys(client, server_session.GetCryptoStream());
199 198
200 return client->num_sent_client_hellos(); 199 return client->num_sent_client_hellos();
201 } 200 }
202 201
203 // static 202 // static
204 int CryptoTestUtils::HandshakeWithFakeClient( 203 int CryptoTestUtils::HandshakeWithFakeClient(
205 MockHelper* helper, 204 MockHelper* helper,
206 PacketSavingConnection* server_conn, 205 PacketSavingConnection* server_conn,
207 QuicCryptoServerStream* server, 206 QuicCryptoServerStream* server,
208 const QuicServerId& server_id, 207 const QuicServerId& server_id,
209 const FakeClientOptions& options) { 208 const FakeClientOptions& options) {
210 PacketSavingConnection* client_conn = 209 PacketSavingConnection* client_conn =
211 new PacketSavingConnection(helper, Perspective::IS_CLIENT); 210 new PacketSavingConnection(helper, Perspective::IS_CLIENT);
212 // Advance the time, because timers do not like uninitialized times. 211 // Advance the time, because timers do not like uninitialized times.
213 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 212 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1));
214 213
215 QuicCryptoClientConfig crypto_config; 214 QuicCryptoClientConfig crypto_config(ProofVerifierForTesting());
216 AsyncTestChannelIDSource* async_channel_id_source = nullptr; 215 AsyncTestChannelIDSource* async_channel_id_source = nullptr;
217 if (options.channel_id_enabled) { 216 if (options.channel_id_enabled) {
218 217
219 ChannelIDSource* source = ChannelIDSourceForTesting(); 218 ChannelIDSource* source = ChannelIDSourceForTesting();
220 if (options.channel_id_source_async) { 219 if (options.channel_id_source_async) {
221 async_channel_id_source = new AsyncTestChannelIDSource(source); 220 async_channel_id_source = new AsyncTestChannelIDSource(source);
222 source = async_channel_id_source; 221 source = async_channel_id_source;
223 } 222 }
224 crypto_config.SetChannelIDSource(source); 223 crypto_config.SetChannelIDSource(source);
225 } 224 }
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(), 225 TestQuicSpdyClientSession client_session(client_conn, DefaultQuicConfig(),
235 server_id, &crypto_config); 226 server_id, &crypto_config);
236 227
237 client_session.GetCryptoStream()->CryptoConnect(); 228 client_session.GetCryptoStream()->CryptoConnect();
238 CHECK_EQ(1u, client_conn->encrypted_packets_.size()); 229 CHECK_EQ(1u, client_conn->encrypted_packets_.size());
239 230
240 CommunicateHandshakeMessagesAndRunCallbacks( 231 CommunicateHandshakeMessagesAndRunCallbacks(
241 client_conn, client_session.GetCryptoStream(), server_conn, server, 232 client_conn, client_session.GetCryptoStream(), server_conn, server,
242 async_channel_id_source); 233 async_channel_id_source);
243 234
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 scoped_ptr<CryptoHandshakeMessage> parsed( 605 scoped_ptr<CryptoHandshakeMessage> parsed(
615 CryptoFramer::ParseMessage(bytes->AsStringPiece())); 606 CryptoFramer::ParseMessage(bytes->AsStringPiece()));
616 CHECK(parsed.get()); 607 CHECK(parsed.get());
617 608
618 va_end(ap); 609 va_end(ap);
619 return *parsed; 610 return *parsed;
620 } 611 }
621 612
622 } // namespace test 613 } // namespace test
623 } // namespace net 614 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698