OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <ostream> | 5 #include <ostream> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "crypto/secure_hash.h" | 10 #include "crypto/secure_hash.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 pub_hex_ = "#" + base::HexEncode(public_value, sizeof(public_value)); | 110 pub_hex_ = "#" + base::HexEncode(public_value, sizeof(public_value)); |
111 | 111 |
112 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( | 112 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( |
113 "CHLO", | 113 "CHLO", |
114 "AEAD", "AESG", | 114 "AEAD", "AESG", |
115 "KEXS", "C255", | 115 "KEXS", "C255", |
116 "PUBS", pub_hex_.c_str(), | 116 "PUBS", pub_hex_.c_str(), |
117 "NONC", nonce_hex_.c_str(), | 117 "NONC", nonce_hex_.c_str(), |
118 "VER\0", client_version_.data(), | 118 "VER\0", client_version_.data(), |
119 "$padding", static_cast<int>(kClientHelloMinimumSize), | 119 "$padding", static_cast<int>(kClientHelloMinimumSize), |
120 NULL); | 120 nullptr); |
121 ShouldSucceed(client_hello); | 121 ShouldSucceed(client_hello); |
122 // The message should be rejected because the source-address token is | 122 // The message should be rejected because the source-address token is |
123 // missing. | 123 // missing. |
124 ASSERT_EQ(kREJ, out_.tag()); | 124 ASSERT_EQ(kREJ, out_.tag()); |
125 const HandshakeFailureReason kRejectReasons[] = { | 125 const HandshakeFailureReason kRejectReasons[] = { |
126 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 126 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
127 }; | 127 }; |
128 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 128 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
129 | 129 |
130 StringPiece srct; | 130 StringPiece srct; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 }; | 327 }; |
328 | 328 |
329 string client_version = QuicUtils::TagToString( | 329 string client_version = QuicUtils::TagToString( |
330 QuicVersionToQuicTag(supported_versions_.front())); | 330 QuicVersionToQuicTag(supported_versions_.front())); |
331 | 331 |
332 for (size_t i = 0; i < arraysize(kBadSNIs); i++) { | 332 for (size_t i = 0; i < arraysize(kBadSNIs); i++) { |
333 ShouldFailMentioning("SNI", InchoateClientHello( | 333 ShouldFailMentioning("SNI", InchoateClientHello( |
334 "CHLO", | 334 "CHLO", |
335 "SNI", kBadSNIs[i], | 335 "SNI", kBadSNIs[i], |
336 "VER\0", client_version.data(), | 336 "VER\0", client_version.data(), |
337 NULL)); | 337 nullptr)); |
338 const HandshakeFailureReason kRejectReasons[] = { | 338 const HandshakeFailureReason kRejectReasons[] = { |
339 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 339 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
340 }; | 340 }; |
341 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 341 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 // TODO(rtenneti): Enable the DefaultCert test after implementing ProofSource. | 345 // TODO(rtenneti): Enable the DefaultCert test after implementing ProofSource. |
346 TEST_F(CryptoServerTest, DISABLED_DefaultCert) { | 346 TEST_F(CryptoServerTest, DISABLED_DefaultCert) { |
347 // Check that the server replies with a default certificate when no SNI is | 347 // Check that the server replies with a default certificate when no SNI is |
348 // specified. | 348 // specified. |
349 ShouldSucceed(InchoateClientHello( | 349 ShouldSucceed(InchoateClientHello( |
350 "CHLO", | 350 "CHLO", |
351 "AEAD", "AESG", | 351 "AEAD", "AESG", |
352 "KEXS", "C255", | 352 "KEXS", "C255", |
353 "SCID", scid_hex_.c_str(), | 353 "SCID", scid_hex_.c_str(), |
354 "#004b5453", srct_hex_.c_str(), | 354 "#004b5453", srct_hex_.c_str(), |
355 "PUBS", pub_hex_.c_str(), | 355 "PUBS", pub_hex_.c_str(), |
356 "NONC", nonce_hex_.c_str(), | 356 "NONC", nonce_hex_.c_str(), |
357 "$padding", static_cast<int>(kClientHelloMinimumSize), | 357 "$padding", static_cast<int>(kClientHelloMinimumSize), |
358 "PDMD", "X509", | 358 "PDMD", "X509", |
359 "VER\0", client_version_.data(), | 359 "VER\0", client_version_.data(), |
360 NULL)); | 360 nullptr)); |
361 | 361 |
362 StringPiece cert, proof; | 362 StringPiece cert, proof; |
363 EXPECT_TRUE(out_.GetStringPiece(kCertificateTag, &cert)); | 363 EXPECT_TRUE(out_.GetStringPiece(kCertificateTag, &cert)); |
364 EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); | 364 EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); |
365 EXPECT_NE(0u, cert.size()); | 365 EXPECT_NE(0u, cert.size()); |
366 EXPECT_NE(0u, proof.size()); | 366 EXPECT_NE(0u, proof.size()); |
367 const HandshakeFailureReason kRejectReasons[] = { | 367 const HandshakeFailureReason kRejectReasons[] = { |
368 CLIENT_NONCE_INVALID_TIME_FAILURE | 368 CLIENT_NONCE_INVALID_TIME_FAILURE |
369 }; | 369 }; |
370 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 370 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
371 } | 371 } |
372 | 372 |
373 TEST_P(CryptoServerTest, TooSmall) { | 373 TEST_P(CryptoServerTest, TooSmall) { |
374 ShouldFailMentioning("too small", CryptoTestUtils::Message( | 374 ShouldFailMentioning("too small", CryptoTestUtils::Message( |
375 "CHLO", | 375 "CHLO", |
376 "VER\0", client_version_.data(), | 376 "VER\0", client_version_.data(), |
377 NULL)); | 377 nullptr)); |
378 const HandshakeFailureReason kRejectReasons[] = { | 378 const HandshakeFailureReason kRejectReasons[] = { |
379 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 379 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
380 }; | 380 }; |
381 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 381 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
382 } | 382 } |
383 | 383 |
384 TEST_P(CryptoServerTest, BadSourceAddressToken) { | 384 TEST_P(CryptoServerTest, BadSourceAddressToken) { |
385 // Invalid source-address tokens should be ignored. | 385 // Invalid source-address tokens should be ignored. |
386 static const char* kBadSourceAddressTokens[] = { | 386 static const char* kBadSourceAddressTokens[] = { |
387 "", | 387 "", |
388 "foo", | 388 "foo", |
389 "#0000", | 389 "#0000", |
390 "#0000000000000000000000000000000000000000", | 390 "#0000000000000000000000000000000000000000", |
391 }; | 391 }; |
392 | 392 |
393 for (size_t i = 0; i < arraysize(kBadSourceAddressTokens); i++) { | 393 for (size_t i = 0; i < arraysize(kBadSourceAddressTokens); i++) { |
394 ShouldSucceed(InchoateClientHello( | 394 ShouldSucceed(InchoateClientHello( |
395 "CHLO", | 395 "CHLO", |
396 "STK", kBadSourceAddressTokens[i], | 396 "STK", kBadSourceAddressTokens[i], |
397 "VER\0", client_version_.data(), | 397 "VER\0", client_version_.data(), |
398 NULL)); | 398 nullptr)); |
399 const HandshakeFailureReason kRejectReasons[] = { | 399 const HandshakeFailureReason kRejectReasons[] = { |
400 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 400 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
401 }; | 401 }; |
402 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 402 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 TEST_P(CryptoServerTest, BadClientNonce) { | 406 TEST_P(CryptoServerTest, BadClientNonce) { |
407 // Invalid nonces should be ignored. | 407 // Invalid nonces should be ignored. |
408 static const char* kBadNonces[] = { | 408 static const char* kBadNonces[] = { |
409 "", | 409 "", |
410 "#0000", | 410 "#0000", |
411 "#0000000000000000000000000000000000000000", | 411 "#0000000000000000000000000000000000000000", |
412 }; | 412 }; |
413 | 413 |
414 for (size_t i = 0; i < arraysize(kBadNonces); i++) { | 414 for (size_t i = 0; i < arraysize(kBadNonces); i++) { |
415 ShouldSucceed(InchoateClientHello( | 415 ShouldSucceed(InchoateClientHello( |
416 "CHLO", | 416 "CHLO", |
417 "NONC", kBadNonces[i], | 417 "NONC", kBadNonces[i], |
418 "VER\0", client_version_.data(), | 418 "VER\0", client_version_.data(), |
419 NULL)); | 419 nullptr)); |
420 const HandshakeFailureReason kRejectReasons[] = { | 420 const HandshakeFailureReason kRejectReasons[] = { |
421 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 421 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
422 }; | 422 }; |
423 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 423 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 TEST_P(CryptoServerTest, DowngradeAttack) { | 427 TEST_P(CryptoServerTest, DowngradeAttack) { |
428 if (supported_versions_.size() == 1) { | 428 if (supported_versions_.size() == 1) { |
429 // No downgrade attack is possible if the server only supports one version. | 429 // No downgrade attack is possible if the server only supports one version. |
430 return; | 430 return; |
431 } | 431 } |
432 // Set the client's preferred version to a supported version that | 432 // Set the client's preferred version to a supported version that |
433 // is not the "current" version (supported_versions_.front()). | 433 // is not the "current" version (supported_versions_.front()). |
434 string bad_version = QuicUtils::TagToString( | 434 string bad_version = QuicUtils::TagToString( |
435 QuicVersionToQuicTag(supported_versions_.back())); | 435 QuicVersionToQuicTag(supported_versions_.back())); |
436 | 436 |
437 ShouldFailMentioning("Downgrade", InchoateClientHello( | 437 ShouldFailMentioning("Downgrade", InchoateClientHello( |
438 "CHLO", | 438 "CHLO", |
439 "VER\0", bad_version.data(), | 439 "VER\0", bad_version.data(), |
440 NULL)); | 440 nullptr)); |
441 const HandshakeFailureReason kRejectReasons[] = { | 441 const HandshakeFailureReason kRejectReasons[] = { |
442 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 442 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
443 }; | 443 }; |
444 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 444 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
445 } | 445 } |
446 | 446 |
447 TEST_P(CryptoServerTest, CorruptServerConfig) { | 447 TEST_P(CryptoServerTest, CorruptServerConfig) { |
448 // This tests corrupted server config. | 448 // This tests corrupted server config. |
449 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 449 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
450 "CHLO", | 450 "CHLO", |
451 "AEAD", "AESG", | 451 "AEAD", "AESG", |
452 "KEXS", "C255", | 452 "KEXS", "C255", |
453 "SCID", (string(1, 'X') + scid_hex_).c_str(), | 453 "SCID", (string(1, 'X') + scid_hex_).c_str(), |
454 "#004b5453", srct_hex_.c_str(), | 454 "#004b5453", srct_hex_.c_str(), |
455 "PUBS", pub_hex_.c_str(), | 455 "PUBS", pub_hex_.c_str(), |
456 "NONC", nonce_hex_.c_str(), | 456 "NONC", nonce_hex_.c_str(), |
457 "VER\0", client_version_.data(), | 457 "VER\0", client_version_.data(), |
458 "$padding", static_cast<int>(kClientHelloMinimumSize), | 458 "$padding", static_cast<int>(kClientHelloMinimumSize), |
459 NULL); | 459 nullptr); |
460 ShouldSucceed(msg); | 460 ShouldSucceed(msg); |
461 ASSERT_EQ(kREJ, out_.tag()); | 461 ASSERT_EQ(kREJ, out_.tag()); |
462 const HandshakeFailureReason kRejectReasons[] = { | 462 const HandshakeFailureReason kRejectReasons[] = { |
463 SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE | 463 SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE |
464 }; | 464 }; |
465 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 465 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
466 } | 466 } |
467 | 467 |
468 TEST_P(CryptoServerTest, CorruptSourceAddressToken) { | 468 TEST_P(CryptoServerTest, CorruptSourceAddressToken) { |
469 // This tests corrupted source address token. | 469 // This tests corrupted source address token. |
470 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 470 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
471 "CHLO", | 471 "CHLO", |
472 "AEAD", "AESG", | 472 "AEAD", "AESG", |
473 "KEXS", "C255", | 473 "KEXS", "C255", |
474 "SCID", scid_hex_.c_str(), | 474 "SCID", scid_hex_.c_str(), |
475 "#004b5453", (string(1, 'X') + srct_hex_).c_str(), | 475 "#004b5453", (string(1, 'X') + srct_hex_).c_str(), |
476 "PUBS", pub_hex_.c_str(), | 476 "PUBS", pub_hex_.c_str(), |
477 "NONC", nonce_hex_.c_str(), | 477 "NONC", nonce_hex_.c_str(), |
478 "VER\0", client_version_.data(), | 478 "VER\0", client_version_.data(), |
479 "$padding", static_cast<int>(kClientHelloMinimumSize), | 479 "$padding", static_cast<int>(kClientHelloMinimumSize), |
480 NULL); | 480 nullptr); |
481 ShouldSucceed(msg); | 481 ShouldSucceed(msg); |
482 ASSERT_EQ(kREJ, out_.tag()); | 482 ASSERT_EQ(kREJ, out_.tag()); |
483 const HandshakeFailureReason kRejectReasons[] = { | 483 const HandshakeFailureReason kRejectReasons[] = { |
484 SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE | 484 SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE |
485 }; | 485 }; |
486 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 486 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
487 } | 487 } |
488 | 488 |
489 TEST_P(CryptoServerTest, CorruptClientNonceAndSourceAddressToken) { | 489 TEST_P(CryptoServerTest, CorruptClientNonceAndSourceAddressToken) { |
490 // This test corrupts client nonce and source address token. | 490 // This test corrupts client nonce and source address token. |
491 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 491 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
492 "CHLO", | 492 "CHLO", |
493 "AEAD", "AESG", | 493 "AEAD", "AESG", |
494 "KEXS", "C255", | 494 "KEXS", "C255", |
495 "SCID", scid_hex_.c_str(), | 495 "SCID", scid_hex_.c_str(), |
496 "#004b5453", (string(1, 'X') + srct_hex_).c_str(), | 496 "#004b5453", (string(1, 'X') + srct_hex_).c_str(), |
497 "PUBS", pub_hex_.c_str(), | 497 "PUBS", pub_hex_.c_str(), |
498 "NONC", (string(1, 'X') + nonce_hex_).c_str(), | 498 "NONC", (string(1, 'X') + nonce_hex_).c_str(), |
499 "VER\0", client_version_.data(), | 499 "VER\0", client_version_.data(), |
500 "$padding", static_cast<int>(kClientHelloMinimumSize), | 500 "$padding", static_cast<int>(kClientHelloMinimumSize), |
501 NULL); | 501 nullptr); |
502 ShouldSucceed(msg); | 502 ShouldSucceed(msg); |
503 ASSERT_EQ(kREJ, out_.tag()); | 503 ASSERT_EQ(kREJ, out_.tag()); |
504 const HandshakeFailureReason kRejectReasons[] = { | 504 const HandshakeFailureReason kRejectReasons[] = { |
505 SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, | 505 SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, |
506 CLIENT_NONCE_INVALID_FAILURE | 506 CLIENT_NONCE_INVALID_FAILURE |
507 }; | 507 }; |
508 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 508 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
509 } | 509 } |
510 | 510 |
511 TEST_P(CryptoServerTest, CorruptMultipleTags) { | 511 TEST_P(CryptoServerTest, CorruptMultipleTags) { |
512 // This test corrupts client nonce, server nonce and source address token. | 512 // This test corrupts client nonce, server nonce and source address token. |
513 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 513 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
514 "CHLO", | 514 "CHLO", |
515 "AEAD", "AESG", | 515 "AEAD", "AESG", |
516 "KEXS", "C255", | 516 "KEXS", "C255", |
517 "SCID", scid_hex_.c_str(), | 517 "SCID", scid_hex_.c_str(), |
518 "#004b5453", (string(1, 'X') + srct_hex_).c_str(), | 518 "#004b5453", (string(1, 'X') + srct_hex_).c_str(), |
519 "PUBS", pub_hex_.c_str(), | 519 "PUBS", pub_hex_.c_str(), |
520 "NONC", (string(1, 'X') + nonce_hex_).c_str(), | 520 "NONC", (string(1, 'X') + nonce_hex_).c_str(), |
521 "SNO\0", (string(1, 'X') + nonce_hex_).c_str(), | 521 "SNO\0", (string(1, 'X') + nonce_hex_).c_str(), |
522 "VER\0", client_version_.data(), | 522 "VER\0", client_version_.data(), |
523 "$padding", static_cast<int>(kClientHelloMinimumSize), | 523 "$padding", static_cast<int>(kClientHelloMinimumSize), |
524 NULL); | 524 nullptr); |
525 ShouldSucceed(msg); | 525 ShouldSucceed(msg); |
526 ASSERT_EQ(kREJ, out_.tag()); | 526 ASSERT_EQ(kREJ, out_.tag()); |
527 const HandshakeFailureReason kRejectReasons[] = { | 527 const HandshakeFailureReason kRejectReasons[] = { |
528 SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, | 528 SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, |
529 CLIENT_NONCE_INVALID_FAILURE, | 529 CLIENT_NONCE_INVALID_FAILURE, |
530 SERVER_NONCE_DECRYPTION_FAILURE, | 530 SERVER_NONCE_DECRYPTION_FAILURE, |
531 }; | 531 }; |
532 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 532 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
533 } | 533 } |
534 | 534 |
535 TEST_P(CryptoServerTest, ReplayProtection) { | 535 TEST_P(CryptoServerTest, ReplayProtection) { |
536 // This tests that disabling replay protection works. | 536 // This tests that disabling replay protection works. |
537 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 537 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
538 "CHLO", | 538 "CHLO", |
539 "AEAD", "AESG", | 539 "AEAD", "AESG", |
540 "KEXS", "C255", | 540 "KEXS", "C255", |
541 "SCID", scid_hex_.c_str(), | 541 "SCID", scid_hex_.c_str(), |
542 "#004b5453", srct_hex_.c_str(), | 542 "#004b5453", srct_hex_.c_str(), |
543 "PUBS", pub_hex_.c_str(), | 543 "PUBS", pub_hex_.c_str(), |
544 "NONC", nonce_hex_.c_str(), | 544 "NONC", nonce_hex_.c_str(), |
545 "VER\0", client_version_.data(), | 545 "VER\0", client_version_.data(), |
546 "$padding", static_cast<int>(kClientHelloMinimumSize), | 546 "$padding", static_cast<int>(kClientHelloMinimumSize), |
547 NULL); | 547 nullptr); |
548 ShouldSucceed(msg); | 548 ShouldSucceed(msg); |
549 // The message should be rejected because the strike-register is still | 549 // The message should be rejected because the strike-register is still |
550 // quiescent. | 550 // quiescent. |
551 ASSERT_EQ(kREJ, out_.tag()); | 551 ASSERT_EQ(kREJ, out_.tag()); |
552 | 552 |
553 const HandshakeFailureReason kRejectReasons[] = { | 553 const HandshakeFailureReason kRejectReasons[] = { |
554 CLIENT_NONCE_INVALID_TIME_FAILURE | 554 CLIENT_NONCE_INVALID_TIME_FAILURE |
555 }; | 555 }; |
556 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 556 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
557 | 557 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 public: | 642 public: |
643 virtual void SetUp() { | 643 virtual void SetUp() { |
644 // Deliberately don't add a config so that we can test this situation. | 644 // Deliberately don't add a config so that we can test this situation. |
645 } | 645 } |
646 }; | 646 }; |
647 | 647 |
648 TEST_P(CryptoServerTestNoConfig, DontCrash) { | 648 TEST_P(CryptoServerTestNoConfig, DontCrash) { |
649 ShouldFailMentioning("No config", InchoateClientHello( | 649 ShouldFailMentioning("No config", InchoateClientHello( |
650 "CHLO", | 650 "CHLO", |
651 "VER\0", client_version_.data(), | 651 "VER\0", client_version_.data(), |
652 NULL)); | 652 nullptr)); |
653 | 653 |
654 const HandshakeFailureReason kRejectReasons[] = { | 654 const HandshakeFailureReason kRejectReasons[] = { |
655 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 655 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
656 }; | 656 }; |
657 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 657 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
658 } | 658 } |
659 | 659 |
660 class AsyncStrikeServerVerificationTest : public CryptoServerTest { | 660 class AsyncStrikeServerVerificationTest : public CryptoServerTest { |
661 protected: | 661 protected: |
662 AsyncStrikeServerVerificationTest() { | 662 AsyncStrikeServerVerificationTest() { |
(...skipping 21 matching lines...) Expand all Loading... |
684 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 684 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
685 "CHLO", | 685 "CHLO", |
686 "AEAD", "AESG", | 686 "AEAD", "AESG", |
687 "KEXS", "C255", | 687 "KEXS", "C255", |
688 "SCID", scid_hex_.c_str(), | 688 "SCID", scid_hex_.c_str(), |
689 "#004b5453", srct_hex_.c_str(), | 689 "#004b5453", srct_hex_.c_str(), |
690 "PUBS", pub_hex_.c_str(), | 690 "PUBS", pub_hex_.c_str(), |
691 "NONC", nonce_hex_.c_str(), | 691 "NONC", nonce_hex_.c_str(), |
692 "VER\0", client_version_.data(), | 692 "VER\0", client_version_.data(), |
693 "$padding", static_cast<int>(kClientHelloMinimumSize), | 693 "$padding", static_cast<int>(kClientHelloMinimumSize), |
694 NULL); | 694 nullptr); |
695 | 695 |
696 // Clear the message tag. | 696 // Clear the message tag. |
697 out_.set_tag(0); | 697 out_.set_tag(0); |
698 | 698 |
699 bool called = false; | 699 bool called = false; |
700 RunValidate(msg, new ValidateCallback(this, true, "", &called)); | 700 RunValidate(msg, new ValidateCallback(this, true, "", &called)); |
701 // The verification request was queued. | 701 // The verification request was queued. |
702 ASSERT_FALSE(called); | 702 ASSERT_FALSE(called); |
703 EXPECT_EQ(0u, out_.tag()); | 703 EXPECT_EQ(0u, out_.tag()); |
704 EXPECT_EQ(1, strike_register_client_->PendingVerifications()); | 704 EXPECT_EQ(1, strike_register_client_->PendingVerifications()); |
(...skipping 13 matching lines...) Expand all Loading... |
718 | 718 |
719 strike_register_client_->RunPendingVerifications(); | 719 strike_register_client_->RunPendingVerifications(); |
720 ASSERT_TRUE(called); | 720 ASSERT_TRUE(called); |
721 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); | 721 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); |
722 // The message should be rejected now. | 722 // The message should be rejected now. |
723 EXPECT_EQ(kREJ, out_.tag()); | 723 EXPECT_EQ(kREJ, out_.tag()); |
724 } | 724 } |
725 | 725 |
726 } // namespace test | 726 } // namespace test |
727 } // namespace net | 727 } // namespace net |
OLD | NEW |