Chromium Code Reviews

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « net/quic/quic_utils.cc ('k') | net/quic/test_tools/quic_config_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 (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 181 matching lines...)
192 192
193 SetupCryptoServerConfigForTest( 193 SetupCryptoServerConfigForTest(
194 server_session.connection()->clock(), 194 server_session.connection()->clock(),
195 server_session.connection()->random_generator(), 195 server_session.connection()->random_generator(),
196 server_session.config(), &crypto_config); 196 server_session.config(), &crypto_config);
197 197
198 QuicCryptoServerStream server(crypto_config, &server_session); 198 QuicCryptoServerStream server(crypto_config, &server_session);
199 server_session.SetCryptoStream(&server); 199 server_session.SetCryptoStream(&server);
200 200
201 // The client's handshake must have been started already. 201 // The client's handshake must have been started already.
202 CHECK_NE(0u, client_conn->packets_.size()); 202 CHECK_NE(0u, client_conn->encrypted_packets_.size());
203 203
204 CommunicateHandshakeMessages(client_conn, client, server_conn, &server); 204 CommunicateHandshakeMessages(client_conn, client, server_conn, &server);
205 205
206 CompareClientAndServerKeys(client, &server); 206 CompareClientAndServerKeys(client, &server);
207 207
208 return client->num_sent_client_hellos(); 208 return client->num_sent_client_hellos();
209 } 209 }
210 210
211 // static 211 // static
212 int CryptoTestUtils::HandshakeWithFakeClient( 212 int CryptoTestUtils::HandshakeWithFakeClient(
(...skipping 24 matching lines...)
237 crypto_config.SetChannelIDSource(source); 237 crypto_config.SetChannelIDSource(source);
238 } 238 }
239 QuicServerId server_id(kServerHostname, kServerPort, is_https, 239 QuicServerId server_id(kServerHostname, kServerPort, is_https,
240 PRIVACY_MODE_DISABLED); 240 PRIVACY_MODE_DISABLED);
241 QuicCryptoClientStream client(server_id, &client_session, 241 QuicCryptoClientStream client(server_id, &client_session,
242 ProofVerifyContextForTesting(), 242 ProofVerifyContextForTesting(),
243 &crypto_config); 243 &crypto_config);
244 client_session.SetCryptoStream(&client); 244 client_session.SetCryptoStream(&client);
245 245
246 client.CryptoConnect(); 246 client.CryptoConnect();
247 CHECK_EQ(1u, client_conn->packets_.size()); 247 CHECK_EQ(1u, client_conn->encrypted_packets_.size());
248 248
249 CommunicateHandshakeMessagesAndRunCallbacks( 249 CommunicateHandshakeMessagesAndRunCallbacks(
250 client_conn, &client, server_conn, server, async_channel_id_source); 250 client_conn, &client, server_conn, server, async_channel_id_source);
251 251
252 CompareClientAndServerKeys(&client, server); 252 CompareClientAndServerKeys(&client, server);
253 253
254 if (options.channel_id_enabled) { 254 if (options.channel_id_enabled) {
255 scoped_ptr<ChannelIDKey> channel_id_key; 255 scoped_ptr<ChannelIDKey> channel_id_key;
256 QuicAsyncStatus status = crypto_config.channel_id_source()->GetChannelIDKey( 256 QuicAsyncStatus status = crypto_config.channel_id_source()->GetChannelIDKey(
257 kServerHostname, &channel_id_key, nullptr); 257 kServerHostname, &channel_id_key, nullptr);
(...skipping 30 matching lines...)
288 288
289 // static 289 // static
290 void CryptoTestUtils::CommunicateHandshakeMessagesAndRunCallbacks( 290 void CryptoTestUtils::CommunicateHandshakeMessagesAndRunCallbacks(
291 PacketSavingConnection* a_conn, 291 PacketSavingConnection* a_conn,
292 QuicCryptoStream* a, 292 QuicCryptoStream* a,
293 PacketSavingConnection* b_conn, 293 PacketSavingConnection* b_conn,
294 QuicCryptoStream* b, 294 QuicCryptoStream* b,
295 CallbackSource* callback_source) { 295 CallbackSource* callback_source) {
296 size_t a_i = 0, b_i = 0; 296 size_t a_i = 0, b_i = 0;
297 while (!a->handshake_confirmed()) { 297 while (!a->handshake_confirmed()) {
298 ASSERT_GT(a_conn->packets_.size(), a_i); 298 ASSERT_GT(a_conn->encrypted_packets_.size(), a_i);
299 LOG(INFO) << "Processing " << a_conn->packets_.size() - a_i 299 VLOG(1) << "Processing " << a_conn->encrypted_packets_.size() - a_i
300 << " packets a->b"; 300 << " packets a->b";
301 MovePackets(a_conn, &a_i, b, b_conn); 301 MovePackets(a_conn, &a_i, b, b_conn);
302 if (callback_source) { 302 if (callback_source) {
303 callback_source->RunPendingCallbacks(); 303 callback_source->RunPendingCallbacks();
304 } 304 }
305 305
306 ASSERT_GT(b_conn->packets_.size(), b_i); 306 ASSERT_GT(b_conn->encrypted_packets_.size(), b_i);
307 LOG(INFO) << "Processing " << b_conn->packets_.size() - b_i 307 VLOG(1) << "Processing " << b_conn->encrypted_packets_.size() - b_i
308 << " packets b->a"; 308 << " packets b->a";
309 MovePackets(b_conn, &b_i, a, a_conn); 309 MovePackets(b_conn, &b_i, a, a_conn);
310 if (callback_source) { 310 if (callback_source) {
311 callback_source->RunPendingCallbacks(); 311 callback_source->RunPendingCallbacks();
312 } 312 }
313 } 313 }
314 } 314 }
315 315
316 // static 316 // static
317 pair<size_t, size_t> CryptoTestUtils::AdvanceHandshake( 317 pair<size_t, size_t> CryptoTestUtils::AdvanceHandshake(
318 PacketSavingConnection* a_conn, 318 PacketSavingConnection* a_conn,
319 QuicCryptoStream* a, 319 QuicCryptoStream* a,
320 size_t a_i, 320 size_t a_i,
321 PacketSavingConnection* b_conn, 321 PacketSavingConnection* b_conn,
322 QuicCryptoStream* b, 322 QuicCryptoStream* b,
323 size_t b_i) { 323 size_t b_i) {
324 LOG(INFO) << "Processing " << a_conn->packets_.size() - a_i 324 VLOG(1) << "Processing " << a_conn->encrypted_packets_.size() - a_i
325 << " packets a->b"; 325 << " packets a->b";
326 MovePackets(a_conn, &a_i, b, b_conn); 326 MovePackets(a_conn, &a_i, b, b_conn);
327 327
328 LOG(INFO) << "Processing " << b_conn->packets_.size() - b_i 328 VLOG(1) << "Processing " << b_conn->encrypted_packets_.size() - b_i
329 << " packets b->a"; 329 << " packets b->a";
330 if (b_conn->packets_.size() - b_i == 2) { 330 if (b_conn->encrypted_packets_.size() - b_i == 2) {
331 LOG(INFO) << "here"; 331 VLOG(1) << "here";
332 } 332 }
333 MovePackets(b_conn, &b_i, a, a_conn); 333 MovePackets(b_conn, &b_i, a, a_conn);
334 334
335 return make_pair(a_i, b_i); 335 return std::make_pair(a_i, b_i);
336 } 336 }
337 337
338 // static 338 // static
339 string CryptoTestUtils::GetValueForTag(const CryptoHandshakeMessage& message, 339 string CryptoTestUtils::GetValueForTag(const CryptoHandshakeMessage& message,
340 QuicTag tag) { 340 QuicTag tag) {
341 QuicTagValueMap::const_iterator it = message.tag_value_map().find(tag); 341 QuicTagValueMap::const_iterator it = message.tag_value_map().find(tag);
342 if (it == message.tag_value_map().end()) { 342 if (it == message.tag_value_map().end()) {
343 return string(); 343 return string();
344 } 344 }
345 return it->second; 345 return it->second;
(...skipping 278 matching lines...)
624 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); 624 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg));
625 scoped_ptr<CryptoHandshakeMessage> parsed( 625 scoped_ptr<CryptoHandshakeMessage> parsed(
626 CryptoFramer::ParseMessage(bytes->AsStringPiece())); 626 CryptoFramer::ParseMessage(bytes->AsStringPiece()));
627 CHECK(parsed.get()); 627 CHECK(parsed.get());
628 628
629 return *parsed; 629 return *parsed;
630 } 630 }
631 631
632 } // namespace test 632 } // namespace test
633 } // namespace net 633 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_utils.cc ('k') | net/quic/test_tools/quic_config_peer.h » ('j') | no next file with comments »

Powered by Google App Engine