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

Side by Side Diff: net/quic/crypto/quic_crypto_client_config_test.cc

Issue 1411063004: Remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enough! 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/crypto/quic_crypto_client_config.h" 5 #include "net/quic/crypto/quic_crypto_client_config.h"
6 6
7 #include "net/quic/crypto/proof_verifier.h" 7 #include "net/quic/crypto/proof_verifier.h"
8 #include "net/quic/quic_server_id.h" 8 #include "net/quic/quic_server_id.h"
9 #include "net/quic/test_tools/crypto_test_utils.h"
9 #include "net/quic/test_tools/mock_random.h" 10 #include "net/quic/test_tools/mock_random.h"
10 #include "net/quic/test_tools/quic_test_utils.h" 11 #include "net/quic/test_tools/quic_test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using std::string; 14 using std::string;
14 using std::vector; 15 using std::vector;
15 16
16 namespace net { 17 namespace net {
17 namespace test { 18 namespace test {
18 namespace { 19 namespace {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 EXPECT_EQ(state.server_config(), other.server_config()); 145 EXPECT_EQ(state.server_config(), other.server_config());
145 EXPECT_EQ(state.source_address_token(), other.source_address_token()); 146 EXPECT_EQ(state.source_address_token(), other.source_address_token());
146 EXPECT_EQ(state.certs(), other.certs()); 147 EXPECT_EQ(state.certs(), other.certs());
147 EXPECT_EQ(1u, other.generation_counter()); 148 EXPECT_EQ(1u, other.generation_counter());
148 EXPECT_FALSE(state.has_server_designated_connection_id()); 149 EXPECT_FALSE(state.has_server_designated_connection_id());
149 EXPECT_FALSE(state.has_server_nonce()); 150 EXPECT_FALSE(state.has_server_nonce());
150 } 151 }
151 152
152 TEST(QuicCryptoClientConfigTest, InchoateChlo) { 153 TEST(QuicCryptoClientConfigTest, InchoateChlo) {
153 QuicCryptoClientConfig::CachedState state; 154 QuicCryptoClientConfig::CachedState state;
154 QuicCryptoClientConfig config; 155 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
155 QuicCryptoNegotiatedParameters params; 156 QuicCryptoNegotiatedParameters params;
156 CryptoHandshakeMessage msg; 157 CryptoHandshakeMessage msg;
157 QuicServerId server_id("www.google.com", 80, false, PRIVACY_MODE_DISABLED); 158 QuicServerId server_id("www.google.com", 80, PRIVACY_MODE_DISABLED);
158 config.FillInchoateClientHello(server_id, QuicVersionMax(), &state, 159 config.FillInchoateClientHello(server_id, QuicVersionMax(), &state,
159 &params, &msg); 160 &params, &msg);
160 161
161 QuicTag cver; 162 QuicTag cver;
162 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kVER, &cver)); 163 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kVER, &cver));
163 EXPECT_EQ(QuicVersionToQuicTag(QuicVersionMax()), cver); 164 EXPECT_EQ(QuicVersionToQuicTag(QuicVersionMax()), cver);
164 } 165 }
165 166
166 TEST(QuicCryptoClientConfigTest, PreferAesGcm) { 167 TEST(QuicCryptoClientConfigTest, PreferAesGcm) {
167 QuicCryptoClientConfig config; 168 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
168 if (config.aead.size() > 1) 169 if (config.aead.size() > 1)
169 EXPECT_NE(kAESG, config.aead[0]); 170 EXPECT_NE(kAESG, config.aead[0]);
170 config.PreferAesGcm(); 171 config.PreferAesGcm();
171 EXPECT_EQ(kAESG, config.aead[0]); 172 EXPECT_EQ(kAESG, config.aead[0]);
172 } 173 }
173 174
174 TEST(QuicCryptoClientConfigTest, InchoateChloSecure) { 175 TEST(QuicCryptoClientConfigTest, InchoateChloSecure) {
175 QuicCryptoClientConfig::CachedState state; 176 QuicCryptoClientConfig::CachedState state;
176 QuicCryptoClientConfig config; 177 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
177 QuicCryptoNegotiatedParameters params; 178 QuicCryptoNegotiatedParameters params;
178 CryptoHandshakeMessage msg; 179 CryptoHandshakeMessage msg;
179 QuicServerId server_id("www.google.com", 443, true, PRIVACY_MODE_DISABLED); 180 QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED);
180 config.FillInchoateClientHello(server_id, QuicVersionMax(), &state, 181 config.FillInchoateClientHello(server_id, QuicVersionMax(), &state,
181 &params, &msg); 182 &params, &msg);
182 183
183 QuicTag pdmd; 184 QuicTag pdmd;
184 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kPDMD, &pdmd)); 185 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kPDMD, &pdmd));
185 EXPECT_EQ(kX509, pdmd); 186 EXPECT_EQ(kX509, pdmd);
186 } 187 }
187 188
188 TEST(QuicCryptoClientConfigTest, InchoateChloSecureNoEcdsa) { 189 TEST(QuicCryptoClientConfigTest, InchoateChloSecureNoEcdsa) {
189 QuicCryptoClientConfig::CachedState state; 190 QuicCryptoClientConfig::CachedState state;
190 QuicCryptoClientConfig config; 191 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
191 config.DisableEcdsa(); 192 config.DisableEcdsa();
192 QuicCryptoNegotiatedParameters params; 193 QuicCryptoNegotiatedParameters params;
193 CryptoHandshakeMessage msg; 194 CryptoHandshakeMessage msg;
194 QuicServerId server_id("www.google.com", 443, true, PRIVACY_MODE_DISABLED); 195 QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED);
195 config.FillInchoateClientHello(server_id, QuicVersionMax(), &state, 196 config.FillInchoateClientHello(server_id, QuicVersionMax(), &state,
196 &params, &msg); 197 &params, &msg);
197 198
198 QuicTag pdmd; 199 QuicTag pdmd;
199 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kPDMD, &pdmd)); 200 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kPDMD, &pdmd));
200 EXPECT_EQ(kX59R, pdmd); 201 EXPECT_EQ(kX59R, pdmd);
201 } 202 }
202 203
203 TEST(QuicCryptoClientConfigTest, FillClientHello) { 204 TEST(QuicCryptoClientConfigTest, FillClientHello) {
204 QuicCryptoClientConfig::CachedState state; 205 QuicCryptoClientConfig::CachedState state;
205 QuicCryptoClientConfig config; 206 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
206 QuicCryptoNegotiatedParameters params; 207 QuicCryptoNegotiatedParameters params;
207 QuicConnectionId kConnectionId = 1234; 208 QuicConnectionId kConnectionId = 1234;
208 string error_details; 209 string error_details;
209 MockRandom rand; 210 MockRandom rand;
210 CryptoHandshakeMessage chlo; 211 CryptoHandshakeMessage chlo;
211 QuicServerId server_id("www.google.com", 80, false, PRIVACY_MODE_DISABLED); 212 QuicServerId server_id("www.google.com", 80, PRIVACY_MODE_DISABLED);
212 config.FillClientHello(server_id, 213 config.FillClientHello(server_id,
213 kConnectionId, 214 kConnectionId,
214 QuicVersionMax(), 215 QuicVersionMax(),
215 &state, 216 &state,
216 QuicWallTime::Zero(), 217 QuicWallTime::Zero(),
217 &rand, 218 &rand,
218 nullptr, // channel_id_key 219 nullptr, // channel_id_key
219 &params, 220 &params,
220 &chlo, 221 &chlo,
221 &error_details); 222 &error_details);
(...skipping 15 matching lines...) Expand all
237 supported_version_tags.push_back( 238 supported_version_tags.push_back(
238 QuicVersionToQuicTag(supported_versions[i - 1])); 239 QuicVersionToQuicTag(supported_versions[i - 1]));
239 } 240 }
240 CryptoHandshakeMessage msg; 241 CryptoHandshakeMessage msg;
241 msg.set_tag(kSHLO); 242 msg.set_tag(kSHLO);
242 msg.SetVector(kVER, supported_version_tags); 243 msg.SetVector(kVER, supported_version_tags);
243 244
244 QuicCryptoClientConfig::CachedState cached; 245 QuicCryptoClientConfig::CachedState cached;
245 QuicCryptoNegotiatedParameters out_params; 246 QuicCryptoNegotiatedParameters out_params;
246 string error; 247 string error;
247 QuicCryptoClientConfig config; 248 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
248 EXPECT_EQ(QUIC_VERSION_NEGOTIATION_MISMATCH, 249 EXPECT_EQ(QUIC_VERSION_NEGOTIATION_MISMATCH,
249 config.ProcessServerHello(msg, 0, supported_versions.front(), 250 config.ProcessServerHello(msg, 0, supported_versions.front(),
250 supported_versions, &cached, &out_params, 251 supported_versions, &cached, &out_params,
251 &error)); 252 &error));
252 EXPECT_EQ("Downgrade attack detected", error); 253 EXPECT_EQ("Downgrade attack detected", error);
253 } 254 }
254 255
255 TEST(QuicCryptoClientConfigTest, InitializeFrom) { 256 TEST(QuicCryptoClientConfigTest, InitializeFrom) {
256 QuicCryptoClientConfig config; 257 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
257 QuicServerId canonical_server_id("www.google.com", 80, false, 258 QuicServerId canonical_server_id("www.google.com", 80, PRIVACY_MODE_DISABLED);
258 PRIVACY_MODE_DISABLED);
259 QuicCryptoClientConfig::CachedState* state = 259 QuicCryptoClientConfig::CachedState* state =
260 config.LookupOrCreate(canonical_server_id); 260 config.LookupOrCreate(canonical_server_id);
261 // TODO(rch): Populate other fields of |state|. 261 // TODO(rch): Populate other fields of |state|.
262 state->set_source_address_token("TOKEN"); 262 state->set_source_address_token("TOKEN");
263 state->SetProofValid(); 263 state->SetProofValid();
264 264
265 QuicServerId other_server_id("mail.google.com", 80, false, 265 QuicServerId other_server_id("mail.google.com", 80, PRIVACY_MODE_DISABLED);
266 PRIVACY_MODE_DISABLED);
267 config.InitializeFrom(other_server_id, canonical_server_id, &config); 266 config.InitializeFrom(other_server_id, canonical_server_id, &config);
268 QuicCryptoClientConfig::CachedState* other = 267 QuicCryptoClientConfig::CachedState* other =
269 config.LookupOrCreate(other_server_id); 268 config.LookupOrCreate(other_server_id);
270 269
271 EXPECT_EQ(state->server_config(), other->server_config()); 270 EXPECT_EQ(state->server_config(), other->server_config());
272 EXPECT_EQ(state->source_address_token(), other->source_address_token()); 271 EXPECT_EQ(state->source_address_token(), other->source_address_token());
273 EXPECT_EQ(state->certs(), other->certs()); 272 EXPECT_EQ(state->certs(), other->certs());
274 EXPECT_EQ(1u, other->generation_counter()); 273 EXPECT_EQ(1u, other->generation_counter());
275 } 274 }
276 275
277 TEST(QuicCryptoClientConfigTest, Canonical) { 276 TEST(QuicCryptoClientConfigTest, Canonical) {
278 QuicCryptoClientConfig config; 277 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
279 config.AddCanonicalSuffix(".google.com"); 278 config.AddCanonicalSuffix(".google.com");
280 QuicServerId canonical_id1("www.google.com", 80, false, 279 QuicServerId canonical_id1("www.google.com", 80, PRIVACY_MODE_DISABLED);
281 PRIVACY_MODE_DISABLED); 280 QuicServerId canonical_id2("mail.google.com", 80, PRIVACY_MODE_DISABLED);
282 QuicServerId canonical_id2("mail.google.com", 80, false,
283 PRIVACY_MODE_DISABLED);
284 QuicCryptoClientConfig::CachedState* state = 281 QuicCryptoClientConfig::CachedState* state =
285 config.LookupOrCreate(canonical_id1); 282 config.LookupOrCreate(canonical_id1);
286 // TODO(rch): Populate other fields of |state|. 283 // TODO(rch): Populate other fields of |state|.
287 state->set_source_address_token("TOKEN"); 284 state->set_source_address_token("TOKEN");
288 state->SetProofValid(); 285 state->SetProofValid();
289 286
290 QuicCryptoClientConfig::CachedState* other = 287 QuicCryptoClientConfig::CachedState* other =
291 config.LookupOrCreate(canonical_id2); 288 config.LookupOrCreate(canonical_id2);
292 289
293 EXPECT_TRUE(state->IsEmpty()); 290 EXPECT_TRUE(state->IsEmpty());
294 EXPECT_EQ(state->server_config(), other->server_config()); 291 EXPECT_EQ(state->server_config(), other->server_config());
295 EXPECT_EQ(state->source_address_token(), other->source_address_token()); 292 EXPECT_EQ(state->source_address_token(), other->source_address_token());
296 EXPECT_EQ(state->certs(), other->certs()); 293 EXPECT_EQ(state->certs(), other->certs());
297 EXPECT_EQ(1u, other->generation_counter()); 294 EXPECT_EQ(1u, other->generation_counter());
298 295
299 QuicServerId different_id("mail.google.org", 80, false, 296 QuicServerId different_id("mail.google.org", 80, PRIVACY_MODE_DISABLED);
300 PRIVACY_MODE_DISABLED);
301 EXPECT_TRUE(config.LookupOrCreate(different_id)->IsEmpty()); 297 EXPECT_TRUE(config.LookupOrCreate(different_id)->IsEmpty());
302 } 298 }
303 299
304 TEST(QuicCryptoClientConfigTest, CanonicalNotUsedIfNotValid) { 300 TEST(QuicCryptoClientConfigTest, CanonicalNotUsedIfNotValid) {
305 QuicCryptoClientConfig config; 301 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
306 config.AddCanonicalSuffix(".google.com"); 302 config.AddCanonicalSuffix(".google.com");
307 QuicServerId canonical_id1("www.google.com", 80, false, 303 QuicServerId canonical_id1("www.google.com", 80, PRIVACY_MODE_DISABLED);
308 PRIVACY_MODE_DISABLED); 304 QuicServerId canonical_id2("mail.google.com", 80, PRIVACY_MODE_DISABLED);
309 QuicServerId canonical_id2("mail.google.com", 80, false,
310 PRIVACY_MODE_DISABLED);
311 QuicCryptoClientConfig::CachedState* state = 305 QuicCryptoClientConfig::CachedState* state =
312 config.LookupOrCreate(canonical_id1); 306 config.LookupOrCreate(canonical_id1);
313 // TODO(rch): Populate other fields of |state|. 307 // TODO(rch): Populate other fields of |state|.
314 state->set_source_address_token("TOKEN"); 308 state->set_source_address_token("TOKEN");
315 309
316 // Do not set the proof as valid, and check that it is not used 310 // Do not set the proof as valid, and check that it is not used
317 // as a canonical entry. 311 // as a canonical entry.
318 EXPECT_TRUE(config.LookupOrCreate(canonical_id2)->IsEmpty()); 312 EXPECT_TRUE(config.LookupOrCreate(canonical_id2)->IsEmpty());
319 } 313 }
320 314
321 TEST(QuicCryptoClientConfigTest, ClearCachedStates) { 315 TEST(QuicCryptoClientConfigTest, ClearCachedStates) {
322 QuicCryptoClientConfig config; 316 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
323 QuicServerId server_id("www.google.com", 80, false, PRIVACY_MODE_DISABLED); 317 QuicServerId server_id("www.google.com", 80, PRIVACY_MODE_DISABLED);
324 QuicCryptoClientConfig::CachedState* state = config.LookupOrCreate(server_id); 318 QuicCryptoClientConfig::CachedState* state = config.LookupOrCreate(server_id);
325 // TODO(rch): Populate other fields of |state|. 319 // TODO(rch): Populate other fields of |state|.
326 vector<string> certs(1); 320 vector<string> certs(1);
327 certs[0] = "Hello Cert"; 321 certs[0] = "Hello Cert";
328 state->SetProof(certs, "signature"); 322 state->SetProof(certs, "signature");
329 state->set_source_address_token("TOKEN"); 323 state->set_source_address_token("TOKEN");
330 state->SetProofValid(); 324 state->SetProofValid();
331 EXPECT_EQ(1u, state->generation_counter()); 325 EXPECT_EQ(1u, state->generation_counter());
332 326
333 // Verify LookupOrCreate returns the same data. 327 // Verify LookupOrCreate returns the same data.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 380 }
387 381
388 TEST(QuicCryptoClientConfigTest, ProcessReject) { 382 TEST(QuicCryptoClientConfigTest, ProcessReject) {
389 CryptoHandshakeMessage rej; 383 CryptoHandshakeMessage rej;
390 FillInDummyReject(&rej, /* stateless */ false); 384 FillInDummyReject(&rej, /* stateless */ false);
391 385
392 // Now process the rejection. 386 // Now process the rejection.
393 QuicCryptoClientConfig::CachedState cached; 387 QuicCryptoClientConfig::CachedState cached;
394 QuicCryptoNegotiatedParameters out_params; 388 QuicCryptoNegotiatedParameters out_params;
395 string error; 389 string error;
396 QuicCryptoClientConfig config; 390 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
397 EXPECT_EQ(QUIC_NO_ERROR, config.ProcessRejection( 391 EXPECT_EQ(QUIC_NO_ERROR, config.ProcessRejection(
398 rej, QuicWallTime::FromUNIXSeconds(0), &cached, 392 rej, QuicWallTime::FromUNIXSeconds(0), &cached,
399 true, // is_https
400 &out_params, &error)); 393 &out_params, &error));
401 EXPECT_FALSE(cached.has_server_designated_connection_id()); 394 EXPECT_FALSE(cached.has_server_designated_connection_id());
402 EXPECT_FALSE(cached.has_server_nonce()); 395 EXPECT_FALSE(cached.has_server_nonce());
403 } 396 }
404 397
405 TEST(QuicCryptoClientConfigTest, ProcessStatelessReject) { 398 TEST(QuicCryptoClientConfigTest, ProcessStatelessReject) {
406 // Create a dummy reject message and mark it as stateless. 399 // Create a dummy reject message and mark it as stateless.
407 CryptoHandshakeMessage rej; 400 CryptoHandshakeMessage rej;
408 FillInDummyReject(&rej, /* stateless */ true); 401 FillInDummyReject(&rej, /* stateless */ true);
409 const QuicConnectionId kConnectionId = 0xdeadbeef; 402 const QuicConnectionId kConnectionId = 0xdeadbeef;
410 const string server_nonce = "SERVER_NONCE"; 403 const string server_nonce = "SERVER_NONCE";
411 rej.SetValue(kRCID, kConnectionId); 404 rej.SetValue(kRCID, kConnectionId);
412 rej.SetStringPiece(kServerNonceTag, server_nonce); 405 rej.SetStringPiece(kServerNonceTag, server_nonce);
413 406
414 // Now process the rejection. 407 // Now process the rejection.
415 QuicCryptoClientConfig::CachedState cached; 408 QuicCryptoClientConfig::CachedState cached;
416 QuicCryptoNegotiatedParameters out_params; 409 QuicCryptoNegotiatedParameters out_params;
417 string error; 410 string error;
418 QuicCryptoClientConfig config; 411 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
419 EXPECT_EQ(QUIC_NO_ERROR, config.ProcessRejection( 412 EXPECT_EQ(QUIC_NO_ERROR, config.ProcessRejection(
420 rej, QuicWallTime::FromUNIXSeconds(0), &cached, 413 rej, QuicWallTime::FromUNIXSeconds(0), &cached,
421 true, // is_https
422 &out_params, &error)); 414 &out_params, &error));
423 EXPECT_TRUE(cached.has_server_designated_connection_id()); 415 EXPECT_TRUE(cached.has_server_designated_connection_id());
424 EXPECT_EQ(kConnectionId, cached.GetNextServerDesignatedConnectionId()); 416 EXPECT_EQ(kConnectionId, cached.GetNextServerDesignatedConnectionId());
425 EXPECT_EQ(server_nonce, cached.GetNextServerNonce()); 417 EXPECT_EQ(server_nonce, cached.GetNextServerNonce());
426 } 418 }
427 419
428 TEST(QuicCryptoClientConfigTest, BadlyFormattedStatelessReject) { 420 TEST(QuicCryptoClientConfigTest, BadlyFormattedStatelessReject) {
429 // Create a dummy reject message and mark it as stateless. Do not 421 // Create a dummy reject message and mark it as stateless. Do not
430 // add an server-designated connection-id. 422 // add an server-designated connection-id.
431 CryptoHandshakeMessage rej; 423 CryptoHandshakeMessage rej;
432 FillInDummyReject(&rej, /* stateless */ true); 424 FillInDummyReject(&rej, /* stateless */ true);
433 425
434 // Now process the rejection. 426 // Now process the rejection.
435 QuicCryptoClientConfig::CachedState cached; 427 QuicCryptoClientConfig::CachedState cached;
436 QuicCryptoNegotiatedParameters out_params; 428 QuicCryptoNegotiatedParameters out_params;
437 string error; 429 string error;
438 QuicCryptoClientConfig config; 430 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
439 EXPECT_EQ( 431 EXPECT_EQ(
440 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, 432 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND,
441 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), &cached, 433 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), &cached,
442 true, // is_https
443 &out_params, &error)); 434 &out_params, &error));
444 EXPECT_FALSE(cached.has_server_designated_connection_id()); 435 EXPECT_FALSE(cached.has_server_designated_connection_id());
445 EXPECT_EQ("Missing kRCID", error); 436 EXPECT_EQ("Missing kRCID", error);
446 } 437 }
447 438
448 TEST(QuicCryptoClientConfigTest, ServerNonceinSHLO_BeforeQ027) { 439 TEST(QuicCryptoClientConfigTest, ServerNonceinSHLO_BeforeQ027) {
449 // Test that in QUIC_VERSION_26 and lower, the the server does not need to 440 // Test that in QUIC_VERSION_26 and lower, the the server does not need to
450 // include a nonce in the SHLO. 441 // include a nonce in the SHLO.
451 CryptoHandshakeMessage msg; 442 CryptoHandshakeMessage msg;
452 msg.set_tag(kSHLO); 443 msg.set_tag(kSHLO);
453 // Choose the lowest version. 444 // Choose the lowest version.
454 QuicVersionVector supported_versions; 445 QuicVersionVector supported_versions;
455 QuicVersion version = QuicSupportedVersions().back(); 446 QuicVersion version = QuicSupportedVersions().back();
456 supported_versions.push_back(version); 447 supported_versions.push_back(version);
457 EXPECT_LE(version, QUIC_VERSION_26); 448 EXPECT_LE(version, QUIC_VERSION_26);
458 QuicTagVector versions; 449 QuicTagVector versions;
459 versions.push_back(QuicVersionToQuicTag(version)); 450 versions.push_back(QuicVersionToQuicTag(version));
460 msg.SetVector(kVER, versions); 451 msg.SetVector(kVER, versions);
461 452
462 QuicCryptoClientConfig config; 453 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
463 QuicCryptoClientConfig::CachedState cached; 454 QuicCryptoClientConfig::CachedState cached;
464 QuicCryptoNegotiatedParameters out_params; 455 QuicCryptoNegotiatedParameters out_params;
465 string error_details; 456 string error_details;
466 config.ProcessServerHello(msg, 0, version, supported_versions, &cached, 457 config.ProcessServerHello(msg, 0, version, supported_versions, &cached,
467 &out_params, &error_details); 458 &out_params, &error_details);
468 EXPECT_NE("server hello missing server nonce", error_details); 459 EXPECT_NE("server hello missing server nonce", error_details);
469 } 460 }
470 461
471 TEST(QuicCryptoClientConfigTest, ServerNonceinSHLO_AfterQ027) { 462 TEST(QuicCryptoClientConfigTest, ServerNonceinSHLO_AfterQ027) {
472 // Test that in QUIC_VERSION_27 and higher, the the server must include a 463 // Test that in QUIC_VERSION_27 and higher, the the server must include a
473 // nonce in the SHLO. 464 // nonce in the SHLO.
474 CryptoHandshakeMessage msg; 465 CryptoHandshakeMessage msg;
475 msg.set_tag(kSHLO); 466 msg.set_tag(kSHLO);
476 // Choose the latest version. 467 // Choose the latest version.
477 QuicVersionVector supported_versions; 468 QuicVersionVector supported_versions;
478 QuicVersion version = QuicSupportedVersions().front(); 469 QuicVersion version = QuicSupportedVersions().front();
479 supported_versions.push_back(version); 470 supported_versions.push_back(version);
480 EXPECT_LE(QUIC_VERSION_27, version); 471 EXPECT_LE(QUIC_VERSION_27, version);
481 QuicTagVector versions; 472 QuicTagVector versions;
482 versions.push_back(QuicVersionToQuicTag(version)); 473 versions.push_back(QuicVersionToQuicTag(version));
483 msg.SetVector(kVER, versions); 474 msg.SetVector(kVER, versions);
484 475
485 QuicCryptoClientConfig config; 476 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting());
486 QuicCryptoClientConfig::CachedState cached; 477 QuicCryptoClientConfig::CachedState cached;
487 QuicCryptoNegotiatedParameters out_params; 478 QuicCryptoNegotiatedParameters out_params;
488 string error_details; 479 string error_details;
489 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, 480 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER,
490 config.ProcessServerHello(msg, 0, version, supported_versions, 481 config.ProcessServerHello(msg, 0, version, supported_versions,
491 &cached, &out_params, &error_details)); 482 &cached, &out_params, &error_details));
492 EXPECT_EQ("server hello missing server nonce", error_details); 483 EXPECT_EQ("server hello missing server nonce", error_details);
493 } 484 }
494 485
495 } // namespace test 486 } // namespace test
496 } // namespace net 487 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_crypto_client_config.cc ('k') | net/quic/crypto/quic_crypto_server_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698