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

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

Issue 1904213002: QUIC: support diversified keys with version 33. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hkdf
Patch Set: Rebase Created 4 years, 8 months 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
« no previous file with comments | « net/quic/crypto/aead_base_decrypter.cc ('k') | net/quic/crypto/crypto_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <cstdint> 6 #include <cstdint>
7 #include <memory> 7 #include <memory>
8 #include <ostream> 8 #include <ostream>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 message, client_address_.address(), server_ip, 289 message, client_address_.address(), server_ip,
290 supported_versions_.front(), &clock_, &crypto_proof_, 290 supported_versions_.front(), &clock_, &crypto_proof_,
291 new ValidateCallback(this, false, error_substr, called)); 291 new ValidateCallback(this, false, error_substr, called));
292 } 292 }
293 293
294 void ProcessValidationResult(const CryptoHandshakeMessage& message, 294 void ProcessValidationResult(const CryptoHandshakeMessage& message,
295 const ValidateCallback::Result& result, 295 const ValidateCallback::Result& result,
296 bool should_succeed, 296 bool should_succeed,
297 const char* error_substr) { 297 const char* error_substr) {
298 IPAddress server_ip; 298 IPAddress server_ip;
299 DiversificationNonce diversification_nonce;
299 string error_details; 300 string error_details;
300 QuicConnectionId server_designated_connection_id = 301 QuicConnectionId server_designated_connection_id =
301 rand_for_id_generation_.RandUint64(); 302 rand_for_id_generation_.RandUint64();
302 QuicErrorCode error = config_.ProcessClientHello( 303 QuicErrorCode error = config_.ProcessClientHello(
303 result, 1 /* ConnectionId */, server_ip, client_address_, 304 result, 1 /* ConnectionId */, server_ip, client_address_,
304 supported_versions_.front(), supported_versions_, 305 supported_versions_.front(), supported_versions_,
305 use_stateless_rejects_, server_designated_connection_id, &clock_, rand_, 306 use_stateless_rejects_, server_designated_connection_id, &clock_, rand_,
306 &compressed_certs_cache_, &params_, &crypto_proof_, &out_, 307 &compressed_certs_cache_, &params_, &crypto_proof_, &out_,
307 &error_details); 308 &diversification_nonce, &error_details);
308 309
309 if (should_succeed) { 310 if (should_succeed) {
310 ASSERT_EQ(error, QUIC_NO_ERROR) << "Message failed with error " 311 ASSERT_EQ(error, QUIC_NO_ERROR) << "Message failed with error "
311 << error_details << ": " 312 << error_details << ": "
312 << message.DebugString(); 313 << message.DebugString();
313 } else { 314 } else {
314 ASSERT_NE(error, QUIC_NO_ERROR) << "Message didn't fail: " 315 ASSERT_NE(error, QUIC_NO_ERROR) << "Message didn't fail: "
315 << message.DebugString(); 316 << message.DebugString();
316 317
317 EXPECT_TRUE(error_details.find(error_substr) != string::npos) 318 EXPECT_TRUE(error_details.find(error_substr) != string::npos)
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 "NONC", nonce_hex_.c_str(), 811 "NONC", nonce_hex_.c_str(),
811 "NONP", nonce_hex_.c_str(), 812 "NONP", nonce_hex_.c_str(),
812 "XLCT", XlctHexString().c_str(), 813 "XLCT", XlctHexString().c_str(),
813 "VER\0", client_version_string_.c_str(), 814 "VER\0", client_version_string_.c_str(),
814 "$padding", static_cast<int>(kClientHelloMinimumSize), 815 "$padding", static_cast<int>(kClientHelloMinimumSize),
815 nullptr); 816 nullptr);
816 // clang-format on 817 // clang-format on
817 818
818 ShouldSucceed(msg); 819 ShouldSucceed(msg);
819 820
820 CheckRejectTag(); 821 if (client_version_ <= QUIC_VERSION_32) {
821 const HandshakeFailureReason kRejectReasons[] = { 822 CheckRejectTag();
822 SERVER_NONCE_REQUIRED_FAILURE}; 823 const HandshakeFailureReason kRejectReasons[] = {
823 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); 824 SERVER_NONCE_REQUIRED_FAILURE};
825 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons));
826 } else {
827 // Even without a server nonce, this ClientHello should be accepted in
828 // version 33.
829 ASSERT_EQ(kSHLO, out_.tag());
830 CheckServerHello(out_);
831 }
824 } 832 }
825 833
826 TEST_P(CryptoServerTest, ProofForSuppliedServerConfig) { 834 TEST_P(CryptoServerTest, ProofForSuppliedServerConfig) {
827 client_address_ = IPEndPoint(Loopback6(), 1234); 835 client_address_ = IPEndPoint(Loopback6(), 1234);
828 // clang-format off 836 // clang-format off
829 CryptoHandshakeMessage msg = CryptoTestUtils::Message( 837 CryptoHandshakeMessage msg = CryptoTestUtils::Message(
830 "CHLO", 838 "CHLO",
831 "AEAD", "AESG", 839 "AEAD", "AESG",
832 "KEXS", "C255", 840 "KEXS", "C255",
833 "PDMD", "X509", 841 "PDMD", "X509",
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 1201
1194 strike_register_client_->RunPendingVerifications(); 1202 strike_register_client_->RunPendingVerifications();
1195 ASSERT_TRUE(called); 1203 ASSERT_TRUE(called);
1196 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); 1204 EXPECT_EQ(0, strike_register_client_->PendingVerifications());
1197 // The message should be rejected now. 1205 // The message should be rejected now.
1198 CheckRejectTag(); 1206 CheckRejectTag();
1199 } 1207 }
1200 1208
1201 } // namespace test 1209 } // namespace test
1202 } // namespace net 1210 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/aead_base_decrypter.cc ('k') | net/quic/crypto/crypto_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698