OLD | NEW |
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/crypto_test_utils.h" |
10 #include "net/quic/test_tools/mock_random.h" | 10 #include "net/quic/test_tools/mock_random.h" |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 string error; | 425 string error; |
426 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); | 426 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); |
427 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, | 427 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, |
428 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), | 428 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), |
429 QuicSupportedVersions().front(), "", | 429 QuicSupportedVersions().front(), "", |
430 &cached, &out_params, &error)); | 430 &cached, &out_params, &error)); |
431 EXPECT_FALSE(cached.has_server_designated_connection_id()); | 431 EXPECT_FALSE(cached.has_server_designated_connection_id()); |
432 EXPECT_EQ("Missing kRCID", error); | 432 EXPECT_EQ("Missing kRCID", error); |
433 } | 433 } |
434 | 434 |
435 TEST(QuicCryptoClientConfigTest, ServerNonceinSHLO_BeforeQ027) { | 435 TEST(QuicCryptoClientConfigTest, ServerNonceinSHLO) { |
436 // Test that in QUIC_VERSION_26 and lower, the the server does not need to | 436 // Test that the server must include a nonce in the SHLO. |
437 // include a nonce in the SHLO. | |
438 CryptoHandshakeMessage msg; | |
439 msg.set_tag(kSHLO); | |
440 // Choose the lowest version. | |
441 QuicVersionVector supported_versions; | |
442 QuicVersion version = QuicSupportedVersions().back(); | |
443 supported_versions.push_back(version); | |
444 EXPECT_LE(version, QUIC_VERSION_26); | |
445 QuicTagVector versions; | |
446 versions.push_back(QuicVersionToQuicTag(version)); | |
447 msg.SetVector(kVER, versions); | |
448 | |
449 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); | |
450 QuicCryptoClientConfig::CachedState cached; | |
451 QuicCryptoNegotiatedParameters out_params; | |
452 string error_details; | |
453 config.ProcessServerHello(msg, 0, version, supported_versions, &cached, | |
454 &out_params, &error_details); | |
455 EXPECT_NE("server hello missing server nonce", error_details); | |
456 } | |
457 | |
458 TEST(QuicCryptoClientConfigTest, ServerNonceinSHLO_AfterQ027) { | |
459 // Test that in QUIC_VERSION_27 and higher, the the server must include a | |
460 // nonce in the SHLO. | |
461 CryptoHandshakeMessage msg; | 437 CryptoHandshakeMessage msg; |
462 msg.set_tag(kSHLO); | 438 msg.set_tag(kSHLO); |
463 // Choose the latest version. | 439 // Choose the latest version. |
464 QuicVersionVector supported_versions; | 440 QuicVersionVector supported_versions; |
465 QuicVersion version = QuicSupportedVersions().front(); | 441 QuicVersion version = QuicSupportedVersions().front(); |
466 supported_versions.push_back(version); | 442 supported_versions.push_back(version); |
467 EXPECT_LE(QUIC_VERSION_27, version); | |
468 QuicTagVector versions; | 443 QuicTagVector versions; |
469 versions.push_back(QuicVersionToQuicTag(version)); | 444 versions.push_back(QuicVersionToQuicTag(version)); |
470 msg.SetVector(kVER, versions); | 445 msg.SetVector(kVER, versions); |
471 | 446 |
472 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); | 447 QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); |
473 QuicCryptoClientConfig::CachedState cached; | 448 QuicCryptoClientConfig::CachedState cached; |
474 QuicCryptoNegotiatedParameters out_params; | 449 QuicCryptoNegotiatedParameters out_params; |
475 string error_details; | 450 string error_details; |
476 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, | 451 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, |
477 config.ProcessServerHello(msg, 0, version, supported_versions, | 452 config.ProcessServerHello(msg, 0, version, supported_versions, |
478 &cached, &out_params, &error_details)); | 453 &cached, &out_params, &error_details)); |
479 EXPECT_EQ("server hello missing server nonce", error_details); | 454 EXPECT_EQ("server hello missing server nonce", error_details); |
480 } | 455 } |
481 | 456 |
482 } // namespace test | 457 } // namespace test |
483 } // namespace net | 458 } // namespace net |
OLD | NEW |