| 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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "crypto/secure_hash.h" | 9 #include "crypto/secure_hash.h" |
| 10 #include "net/quic/crypto/cert_compressor.h" | 10 #include "net/quic/crypto/cert_compressor.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 StringPiece cert, proof, cert_sct; | 500 StringPiece cert, proof, cert_sct; |
| 501 EXPECT_FALSE(out_.GetStringPiece(kCertificateTag, &cert)); | 501 EXPECT_FALSE(out_.GetStringPiece(kCertificateTag, &cert)); |
| 502 EXPECT_FALSE(out_.GetStringPiece(kPROF, &proof)); | 502 EXPECT_FALSE(out_.GetStringPiece(kPROF, &proof)); |
| 503 EXPECT_FALSE(out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); | 503 EXPECT_FALSE(out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); |
| 504 const HandshakeFailureReason kRejectReasons[] = { | 504 const HandshakeFailureReason kRejectReasons[] = { |
| 505 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; | 505 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; |
| 506 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 506 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
| 507 } | 507 } |
| 508 | 508 |
| 509 TEST_P(CryptoServerTest, RejectTooLargeButValidSTK) { | 509 TEST_P(CryptoServerTest, RejectTooLargeButValidSTK) { |
| 510 ValueRestore<bool> old_flag(&FLAGS_quic_validate_stk_without_scid, true); | |
| 511 // Check that the server replies with no certificate when a CHLO is | 510 // Check that the server replies with no certificate when a CHLO is |
| 512 // constructed with a PDMD but no SKT when the REJ would be too large. | 511 // constructed with a PDMD but no SKT when the REJ would be too large. |
| 513 // clang-format off | 512 // clang-format off |
| 514 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 513 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
| 515 "CHLO", | 514 "CHLO", |
| 516 "AEAD", "AESG", | 515 "AEAD", "AESG", |
| 517 "KEXS", "C255", | 516 "KEXS", "C255", |
| 518 "PUBS", pub_hex_.c_str(), | 517 "PUBS", pub_hex_.c_str(), |
| 519 "NONC", nonce_hex_.c_str(), | 518 "NONC", nonce_hex_.c_str(), |
| 520 "#004b5453", srct_hex_.c_str(), | 519 "#004b5453", srct_hex_.c_str(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 533 EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); | 532 EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); |
| 534 EXPECT_EQ(client_version_ > QUIC_VERSION_29, | 533 EXPECT_EQ(client_version_ > QUIC_VERSION_29, |
| 535 out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); | 534 out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); |
| 536 EXPECT_NE(0u, cert.size()); | 535 EXPECT_NE(0u, cert.size()); |
| 537 EXPECT_NE(0u, proof.size()); | 536 EXPECT_NE(0u, proof.size()); |
| 538 const HandshakeFailureReason kRejectReasons[] = { | 537 const HandshakeFailureReason kRejectReasons[] = { |
| 539 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; | 538 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; |
| 540 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 539 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
| 541 } | 540 } |
| 542 | 541 |
| 543 TEST_P(CryptoServerTest, RejectTooLargeButValidSTKWithoutFlag) { | |
| 544 ValueRestore<bool> old_flag(&FLAGS_quic_validate_stk_without_scid, false); | |
| 545 // Check that the server replies with no certificate when a CHLO is | |
| 546 // constructed with a PDMD but no SKT when the REJ would be too large. | |
| 547 // clang-format off | |
| 548 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | |
| 549 "CHLO", | |
| 550 "AEAD", "AESG", | |
| 551 "KEXS", "C255", | |
| 552 "PUBS", pub_hex_.c_str(), | |
| 553 "NONC", nonce_hex_.c_str(), | |
| 554 "#004b5453", srct_hex_.c_str(), | |
| 555 "PDMD", "X509", | |
| 556 "VER\0", client_version_string_.c_str(), | |
| 557 "$padding", static_cast<int>(kClientHelloMinimumSize), | |
| 558 nullptr); | |
| 559 // clang-format on | |
| 560 | |
| 561 // The REJ will be larger than the CHLO so no PROF or CRT will be sent. | |
| 562 config_.set_chlo_multiplier(1); | |
| 563 | |
| 564 ShouldSucceed(msg); | |
| 565 StringPiece cert, proof, cert_sct; | |
| 566 EXPECT_FALSE(out_.GetStringPiece(kCertificateTag, &cert)); | |
| 567 EXPECT_FALSE(out_.GetStringPiece(kPROF, &proof)); | |
| 568 EXPECT_FALSE(out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); | |
| 569 const HandshakeFailureReason kRejectReasons[] = { | |
| 570 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; | |
| 571 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | |
| 572 } | |
| 573 | |
| 574 TEST_P(CryptoServerTest, TooSmall) { | 542 TEST_P(CryptoServerTest, TooSmall) { |
| 575 // clang-format off | 543 // clang-format off |
| 576 ShouldFailMentioning("too small", CryptoTestUtils::Message( | 544 ShouldFailMentioning("too small", CryptoTestUtils::Message( |
| 577 "CHLO", | 545 "CHLO", |
| 578 "VER\0", client_version_string_.c_str(), | 546 "VER\0", client_version_string_.c_str(), |
| 579 nullptr)); | 547 nullptr)); |
| 580 // clang-format on | 548 // clang-format on |
| 581 const HandshakeFailureReason kRejectReasons[] = { | 549 const HandshakeFailureReason kRejectReasons[] = { |
| 582 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; | 550 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; |
| 583 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 551 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 | 1160 |
| 1193 strike_register_client_->RunPendingVerifications(); | 1161 strike_register_client_->RunPendingVerifications(); |
| 1194 ASSERT_TRUE(called); | 1162 ASSERT_TRUE(called); |
| 1195 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); | 1163 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); |
| 1196 // The message should be rejected now. | 1164 // The message should be rejected now. |
| 1197 CheckRejectTag(); | 1165 CheckRejectTag(); |
| 1198 } | 1166 } |
| 1199 | 1167 |
| 1200 } // namespace test | 1168 } // namespace test |
| 1201 } // namespace net | 1169 } // namespace net |
| OLD | NEW |