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

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

Issue 1979763002: Landing Recent QUIC changes until Sun May 8 00:39:29 2016 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/quic_test_utils.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 <openssl/bn.h> 7 #include <openssl/bn.h>
8 #include <openssl/ec.h> 8 #include <openssl/ec.h>
9 #include <openssl/ecdsa.h> 9 #include <openssl/ecdsa.h>
10 #include <openssl/evp.h> 10 #include <openssl/evp.h>
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 CryptoTestUtils::FakeServerOptions::FakeServerOptions() 264 CryptoTestUtils::FakeServerOptions::FakeServerOptions()
265 : token_binding_enabled(false) {} 265 : token_binding_enabled(false) {}
266 266
267 CryptoTestUtils::FakeClientOptions::FakeClientOptions() 267 CryptoTestUtils::FakeClientOptions::FakeClientOptions()
268 : channel_id_enabled(false), 268 : channel_id_enabled(false),
269 channel_id_source_async(false), 269 channel_id_source_async(false),
270 token_binding_enabled(false) {} 270 token_binding_enabled(false) {}
271 271
272 // static 272 // static
273 int CryptoTestUtils::HandshakeWithFakeServer( 273 int CryptoTestUtils::HandshakeWithFakeServer(
274 MockConnectionHelper* helper, 274 MockQuicConnectionHelper* helper,
275 MockAlarmFactory* alarm_factory, 275 MockAlarmFactory* alarm_factory,
276 PacketSavingConnection* client_conn, 276 PacketSavingConnection* client_conn,
277 QuicCryptoClientStream* client, 277 QuicCryptoClientStream* client,
278 const FakeServerOptions& options) { 278 const FakeServerOptions& options) {
279 PacketSavingConnection* server_conn = 279 PacketSavingConnection* server_conn =
280 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_SERVER, 280 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_SERVER,
281 client_conn->supported_versions()); 281 client_conn->supported_versions());
282 282
283 QuicConfig config = DefaultQuicConfig(); 283 QuicConfig config = DefaultQuicConfig();
284 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, 284 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING,
(...skipping 13 matching lines...) Expand all
298 298
299 CommunicateHandshakeMessages(client_conn, client, server_conn, 299 CommunicateHandshakeMessages(client_conn, client, server_conn,
300 server_session.GetCryptoStream()); 300 server_session.GetCryptoStream());
301 CompareClientAndServerKeys(client, server_session.GetCryptoStream()); 301 CompareClientAndServerKeys(client, server_session.GetCryptoStream());
302 302
303 return client->num_sent_client_hellos(); 303 return client->num_sent_client_hellos();
304 } 304 }
305 305
306 // static 306 // static
307 int CryptoTestUtils::HandshakeWithFakeClient( 307 int CryptoTestUtils::HandshakeWithFakeClient(
308 MockConnectionHelper* helper, 308 MockQuicConnectionHelper* helper,
309 MockAlarmFactory* alarm_factory, 309 MockAlarmFactory* alarm_factory,
310 PacketSavingConnection* server_conn, 310 PacketSavingConnection* server_conn,
311 QuicCryptoServerStream* server, 311 QuicCryptoServerStream* server,
312 const QuicServerId& server_id, 312 const QuicServerId& server_id,
313 const FakeClientOptions& options) { 313 const FakeClientOptions& options) {
314 PacketSavingConnection* client_conn = 314 PacketSavingConnection* client_conn =
315 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_CLIENT); 315 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_CLIENT);
316 // Advance the time, because timers do not like uninitialized times. 316 // Advance the time, because timers do not like uninitialized times.
317 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 317 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1));
318 318
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 size_t index = *inout_packet_index; 785 size_t index = *inout_packet_index;
786 for (; index < source_conn->encrypted_packets_.size(); index++) { 786 for (; index < source_conn->encrypted_packets_.size(); index++) {
787 if (!framer.ProcessPacket(*source_conn->encrypted_packets_[index])) { 787 if (!framer.ProcessPacket(*source_conn->encrypted_packets_[index])) {
788 // The framer will be unable to decrypt forward-secure packets sent after 788 // The framer will be unable to decrypt forward-secure packets sent after
789 // the handshake is complete. Don't treat them as handshake packets. 789 // the handshake is complete. Don't treat them as handshake packets.
790 break; 790 break;
791 } 791 }
792 792
793 for (const QuicStreamFrame* stream_frame : framer.stream_frames()) { 793 for (const QuicStreamFrame* stream_frame : framer.stream_frames()) {
794 ASSERT_TRUE(crypto_framer.ProcessInput( 794 ASSERT_TRUE(crypto_framer.ProcessInput(
795 StringPiece(stream_frame->frame_buffer, stream_frame->frame_length))); 795 StringPiece(stream_frame->data_buffer, stream_frame->data_length)));
796 ASSERT_FALSE(crypto_visitor.error()); 796 ASSERT_FALSE(crypto_visitor.error());
797 } 797 }
798 } 798 }
799 *inout_packet_index = index; 799 *inout_packet_index = index;
800 800
801 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer()); 801 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer());
802 802
803 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining()); 803 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining());
804 804
805 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) { 805 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) {
806 dest_stream->OnHandshakeMessage(message); 806 dest_stream->OnHandshakeMessage(message);
807 } 807 }
808 } 808 }
809 809
810 } // namespace test 810 } // namespace test
811 } // namespace net 811 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698