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

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

Issue 449273002: Along with sending the SCUP message, this CL includes small fixes which (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Trigger_QUIC_tracegraf_72571464
Patch Set: Created 6 years, 4 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/quic_sent_packet_manager.cc ('k') | no next file » | 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const vector<CryptoHandshakeMessage>& messages() const { 55 const vector<CryptoHandshakeMessage>& messages() const {
56 return messages_; 56 return messages_;
57 } 57 }
58 58
59 private: 59 private:
60 bool error_; 60 bool error_;
61 vector<CryptoHandshakeMessage> messages_; 61 vector<CryptoHandshakeMessage> messages_;
62 }; 62 };
63 63
64 // MovePackets parses crypto handshake messages from packet number 64 // MovePackets parses crypto handshake messages from packet number
65 // |*inout_packet_index| through to the last packet and has |dest_stream| 65 // |*inout_packet_index| through to the last packet (or until a packet fails to
66 // process them. |*inout_packet_index| is updated with an index one greater 66 // decrypt) and has |dest_stream| process them. |*inout_packet_index| is updated
67 // than the last packet processed. 67 // with an index one greater than the last packet processed.
68 void MovePackets(PacketSavingConnection* source_conn, 68 void MovePackets(PacketSavingConnection* source_conn,
69 size_t *inout_packet_index, 69 size_t *inout_packet_index,
70 QuicCryptoStream* dest_stream, 70 QuicCryptoStream* dest_stream,
71 PacketSavingConnection* dest_conn) { 71 PacketSavingConnection* dest_conn) {
72 SimpleQuicFramer framer(source_conn->supported_versions()); 72 SimpleQuicFramer framer(source_conn->supported_versions());
73 CryptoFramer crypto_framer; 73 CryptoFramer crypto_framer;
74 CryptoFramerVisitor crypto_visitor; 74 CryptoFramerVisitor crypto_visitor;
75 75
76 // In order to properly test the code we need to perform encryption and 76 // In order to properly test the code we need to perform encryption and
77 // decryption so that the crypters latch when expected. The crypters are in 77 // decryption so that the crypters latch when expected. The crypters are in
78 // |dest_conn|, but we don't want to try and use them there. Instead we swap 78 // |dest_conn|, but we don't want to try and use them there. Instead we swap
79 // them into |framer|, perform the decryption with them, and then swap them 79 // them into |framer|, perform the decryption with them, and then swap them
80 // back. 80 // back.
81 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer()); 81 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer());
82 82
83 crypto_framer.set_visitor(&crypto_visitor); 83 crypto_framer.set_visitor(&crypto_visitor);
84 84
85 size_t index = *inout_packet_index; 85 size_t index = *inout_packet_index;
86 for (; index < source_conn->encrypted_packets_.size(); index++) { 86 for (; index < source_conn->encrypted_packets_.size(); index++) {
87 ASSERT_TRUE(framer.ProcessPacket(*source_conn->encrypted_packets_[index])); 87 if (!framer.ProcessPacket(*source_conn->encrypted_packets_[index])) {
88 // The framer will be unable to decrypt forward-secure packets sent after
89 // the handshake is complete. Don't treat them as handshake packets.
90 break;
91 }
92
88 for (vector<QuicStreamFrame>::const_iterator 93 for (vector<QuicStreamFrame>::const_iterator
89 i = framer.stream_frames().begin(); 94 i = framer.stream_frames().begin();
90 i != framer.stream_frames().end(); ++i) { 95 i != framer.stream_frames().end(); ++i) {
91 scoped_ptr<string> frame_data(i->GetDataAsString()); 96 scoped_ptr<string> frame_data(i->GetDataAsString());
92 ASSERT_TRUE(crypto_framer.ProcessInput(*frame_data)); 97 ASSERT_TRUE(crypto_framer.ProcessInput(*frame_data));
93 ASSERT_FALSE(crypto_visitor.error()); 98 ASSERT_FALSE(crypto_visitor.error());
94 } 99 }
95 } 100 }
96 *inout_packet_index = index; 101 *inout_packet_index = index;
97 102
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); 629 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg));
625 scoped_ptr<CryptoHandshakeMessage> parsed( 630 scoped_ptr<CryptoHandshakeMessage> parsed(
626 CryptoFramer::ParseMessage(bytes->AsStringPiece())); 631 CryptoFramer::ParseMessage(bytes->AsStringPiece()));
627 CHECK(parsed.get()); 632 CHECK(parsed.get());
628 633
629 return *parsed; 634 return *parsed;
630 } 635 }
631 636
632 } // namespace test 637 } // namespace test
633 } // namespace net 638 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698