| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 "PDMD", "X509", | 358 "PDMD", "X509", |
| 359 "VER\0", client_version_.data(), | 359 "VER\0", client_version_.data(), |
| 360 NULL)); | 360 NULL)); |
| 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_UNKNOWN_FAILURE | 368 CLIENT_NONCE_INVALID_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 NULL)); |
| 378 const HandshakeFailureReason kRejectReasons[] = { | 378 const HandshakeFailureReason kRejectReasons[] = { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 NULL); |
| 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_UNKNOWN_FAILURE | 554 CLIENT_NONCE_INVALID_FAILURE |
| 555 }; | 555 }; |
| 556 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 556 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
| 557 | 557 |
| 558 config_.set_replay_protection(false); | 558 config_.set_replay_protection(false); |
| 559 | 559 |
| 560 ShouldSucceed(msg); | 560 ShouldSucceed(msg); |
| 561 // The message should be accepted now. | 561 // The message should be accepted now. |
| 562 ASSERT_EQ(kSHLO, out_.tag()); | 562 ASSERT_EQ(kSHLO, out_.tag()); |
| 563 CheckServerHello(out_); | 563 CheckServerHello(out_); |
| 564 | 564 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 NULL)); |
| 653 | 653 |
| 654 const HandshakeFailureReason kRejectReasons[] = { | 654 const HandshakeFailureReason kRejectReasons[] = { |
| 655 CLIENT_NONCE_UNKNOWN_FAILURE | 655 CLIENT_NONCE_INVALID_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() { |
| 663 } | 663 } |
| 664 | 664 |
| 665 virtual void SetUp() { | 665 virtual void SetUp() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |