OLD | NEW |
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 : channel_id_enabled(false), channel_id_source_async(false) {} | 170 : channel_id_enabled(false), channel_id_source_async(false) {} |
171 | 171 |
172 // static | 172 // static |
173 int CryptoTestUtils::HandshakeWithFakeServer( | 173 int CryptoTestUtils::HandshakeWithFakeServer( |
174 MockHelper* helper, | 174 MockConnectionHelper* helper, |
175 PacketSavingConnection* client_conn, | 175 PacketSavingConnection* client_conn, |
176 QuicCryptoClientStream* client) { | 176 QuicCryptoClientStream* client) { |
177 PacketSavingConnection* server_conn = new PacketSavingConnection( | 177 PacketSavingConnection* server_conn = new PacketSavingConnection( |
178 helper, Perspective::IS_SERVER, client_conn->supported_versions()); | 178 helper, Perspective::IS_SERVER, client_conn->supported_versions()); |
179 | 179 |
180 QuicConfig config = DefaultQuicConfig(); | 180 QuicConfig config = DefaultQuicConfig(); |
181 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, | 181 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, |
182 QuicRandom::GetInstance(), | 182 QuicRandom::GetInstance(), |
183 ProofSourceForTesting()); | 183 ProofSourceForTesting()); |
184 SetupCryptoServerConfigForTest(server_conn->clock(), | 184 SetupCryptoServerConfigForTest(server_conn->clock(), |
185 server_conn->random_generator(), &config, | 185 server_conn->random_generator(), &config, |
186 &crypto_config); | 186 &crypto_config); |
187 | 187 |
188 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config); | 188 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config); |
189 | 189 |
190 // The client's handshake must have been started already. | 190 // The client's handshake must have been started already. |
191 CHECK_NE(0u, client_conn->encrypted_packets_.size()); | 191 CHECK_NE(0u, client_conn->encrypted_packets_.size()); |
192 | 192 |
193 CommunicateHandshakeMessages(client_conn, client, server_conn, | 193 CommunicateHandshakeMessages(client_conn, client, server_conn, |
194 server_session.GetCryptoStream()); | 194 server_session.GetCryptoStream()); |
195 CompareClientAndServerKeys(client, server_session.GetCryptoStream()); | 195 CompareClientAndServerKeys(client, server_session.GetCryptoStream()); |
196 | 196 |
197 return client->num_sent_client_hellos(); | 197 return client->num_sent_client_hellos(); |
198 } | 198 } |
199 | 199 |
200 // static | 200 // static |
201 int CryptoTestUtils::HandshakeWithFakeClient( | 201 int CryptoTestUtils::HandshakeWithFakeClient( |
202 MockHelper* helper, | 202 MockConnectionHelper* helper, |
203 PacketSavingConnection* server_conn, | 203 PacketSavingConnection* server_conn, |
204 QuicCryptoServerStream* server, | 204 QuicCryptoServerStream* server, |
205 const QuicServerId& server_id, | 205 const QuicServerId& server_id, |
206 const FakeClientOptions& options) { | 206 const FakeClientOptions& options) { |
207 PacketSavingConnection* client_conn = | 207 PacketSavingConnection* client_conn = |
208 new PacketSavingConnection(helper, Perspective::IS_CLIENT); | 208 new PacketSavingConnection(helper, Perspective::IS_CLIENT); |
209 // Advance the time, because timers do not like uninitialized times. | 209 // Advance the time, because timers do not like uninitialized times. |
210 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 210 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
211 | 211 |
212 QuicCryptoClientConfig crypto_config(ProofVerifierForTesting()); | 212 QuicCryptoClientConfig crypto_config(ProofVerifierForTesting()); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 scoped_ptr<CryptoHandshakeMessage> parsed( | 603 scoped_ptr<CryptoHandshakeMessage> parsed( |
604 CryptoFramer::ParseMessage(bytes->AsStringPiece())); | 604 CryptoFramer::ParseMessage(bytes->AsStringPiece())); |
605 CHECK(parsed.get()); | 605 CHECK(parsed.get()); |
606 | 606 |
607 va_end(ap); | 607 va_end(ap); |
608 return *parsed; | 608 return *parsed; |
609 } | 609 } |
610 | 610 |
611 } // namespace test | 611 } // namespace test |
612 } // namespace net | 612 } // namespace net |
OLD | NEW |