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

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

Issue 1437023002: Landing Recent QUIC changes until 2015-11-09 20:32 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « net/quic/reliable_quic_stream.cc ('k') | net/quic/test_tools/crypto_test_utils.cc » ('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 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 5 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
7 7
8 #include <stdarg.h> 8 #include <stdarg.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // this source. 47 // this source.
48 class CallbackSource { 48 class CallbackSource {
49 public: 49 public:
50 virtual ~CallbackSource() {} 50 virtual ~CallbackSource() {}
51 51
52 // Runs pending callbacks from this source. If there is no pending 52 // Runs pending callbacks from this source. If there is no pending
53 // callback, does nothing. 53 // callback, does nothing.
54 virtual void RunPendingCallbacks() = 0; 54 virtual void RunPendingCallbacks() = 0;
55 }; 55 };
56 56
57 // FakeServerOptions bundles together a number of options for configuring the
58 // server in HandshakeWithFakeServer.
59 struct FakeServerOptions {
60 FakeServerOptions();
61
62 // If token_binding_enabled is true, then the server will attempt to
63 // negotiate Token Binding.
64 bool token_binding_enabled;
65 };
66
57 // FakeClientOptions bundles together a number of options for configuring 67 // FakeClientOptions bundles together a number of options for configuring
58 // HandshakeWithFakeClient. 68 // HandshakeWithFakeClient.
59 struct FakeClientOptions { 69 struct FakeClientOptions {
60 FakeClientOptions(); 70 FakeClientOptions();
61 71
62 // If channel_id_enabled is true then the client will attempt to send a 72 // If channel_id_enabled is true then the client will attempt to send a
63 // ChannelID. 73 // ChannelID.
64 bool channel_id_enabled; 74 bool channel_id_enabled;
65 75
66 // If channel_id_source_async is true then the client will use an async 76 // If channel_id_source_async is true then the client will use an async
67 // ChannelIDSource for testing. Ignored if channel_id_enabled is false. 77 // ChannelIDSource for testing. Ignored if channel_id_enabled is false.
68 bool channel_id_source_async; 78 bool channel_id_source_async;
79
80 // If token_binding_enabled is true, then the client will attempt to
81 // negotiate Token Binding.
82 bool token_binding_enabled;
69 }; 83 };
70 84
71 // returns: the number of client hellos that the client sent. 85 // returns: the number of client hellos that the client sent.
72 static int HandshakeWithFakeServer(MockConnectionHelper* helper, 86 static int HandshakeWithFakeServer(MockConnectionHelper* helper,
73 PacketSavingConnection* client_conn, 87 PacketSavingConnection* client_conn,
74 QuicCryptoClientStream* client); 88 QuicCryptoClientStream* client,
89 const FakeServerOptions& options);
75 90
76 // returns: the number of client hellos that the client sent. 91 // returns: the number of client hellos that the client sent.
77 static int HandshakeWithFakeClient(MockConnectionHelper* helper, 92 static int HandshakeWithFakeClient(MockConnectionHelper* helper,
78 PacketSavingConnection* server_conn, 93 PacketSavingConnection* server_conn,
79 QuicCryptoServerStream* server, 94 QuicCryptoServerStream* server,
80 const QuicServerId& server_id, 95 const QuicServerId& server_id,
81 const FakeClientOptions& options); 96 const FakeClientOptions& options);
82 97
83 // SetupCryptoServerConfigForTest configures |config| and |crypto_config| 98 // SetupCryptoServerConfigForTest configures |config| and |crypto_config|
84 // with sensible defaults for testing. 99 // with sensible defaults for testing.
85 static void SetupCryptoServerConfigForTest( 100 static void SetupCryptoServerConfigForTest(
86 const QuicClock* clock, 101 const QuicClock* clock,
87 QuicRandom* rand, 102 QuicRandom* rand,
88 QuicConfig* config, 103 QuicConfig* config,
89 QuicCryptoServerConfig* crypto_config); 104 QuicCryptoServerConfig* crypto_config,
105 const FakeServerOptions& options);
90 106
91 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until 107 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until
92 // |a|'s handshake has completed. 108 // |a|'s handshake has completed.
93 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn, 109 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn,
94 QuicCryptoStream* a, 110 QuicCryptoStream* a,
95 PacketSavingConnection* b_conn, 111 PacketSavingConnection* b_conn,
96 QuicCryptoStream* b); 112 QuicCryptoStream* b);
97 113
98 // CommunicateHandshakeMessagesAndRunCallbacks moves messages from |a| to |b| 114 // CommunicateHandshakeMessagesAndRunCallbacks moves messages from |a| to |b|
99 // and back until |a|'s handshake has completed. If |callback_source| is not 115 // and back until |a|'s handshake has completed. If |callback_source| is not
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // "SNI", "www.example.com", 174 // "SNI", "www.example.com",
159 // nullptr); 175 // nullptr);
160 static CryptoHandshakeMessage Message(const char* message_tag, ...); 176 static CryptoHandshakeMessage Message(const char* message_tag, ...);
161 177
162 // ChannelIDSourceForTesting returns a ChannelIDSource that generates keys 178 // ChannelIDSourceForTesting returns a ChannelIDSource that generates keys
163 // deterministically based on the hostname given in the GetChannelIDKey call. 179 // deterministically based on the hostname given in the GetChannelIDKey call.
164 // This ChannelIDSource works in synchronous mode, i.e., its GetChannelIDKey 180 // This ChannelIDSource works in synchronous mode, i.e., its GetChannelIDKey
165 // method never returns QUIC_PENDING. 181 // method never returns QUIC_PENDING.
166 static ChannelIDSource* ChannelIDSourceForTesting(); 182 static ChannelIDSource* ChannelIDSourceForTesting();
167 183
184 // MovePackets parses crypto handshake messages from packet number
185 // |*inout_packet_index| through to the last packet (or until a packet fails
186 // to decrypt) and has |dest_stream| process them. |*inout_packet_index| is
187 // updated with an index one greater than the last packet processed.
188 static void MovePackets(PacketSavingConnection* source_conn,
189 size_t* inout_packet_index,
190 QuicCryptoStream* dest_stream,
191 PacketSavingConnection* dest_conn);
192
168 private: 193 private:
169 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, 194 static void CompareClientAndServerKeys(QuicCryptoClientStream* client,
170 QuicCryptoServerStream* server); 195 QuicCryptoServerStream* server);
171 196
172 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); 197 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils);
173 }; 198 };
174 199
175 } // namespace test 200 } // namespace test
176 201
177 } // namespace net 202 } // namespace net
178 203
179 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 204 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream.cc ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698