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

Side by Side Diff: net/quic/core/crypto/quic_crypto_server_config.cc

Issue 2515613002: deprecate FLAGS_quic_disable_pre_34 (Closed)
Patch Set: Created 4 years, 1 month 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/core/crypto/quic_crypto_client_config_test.cc ('k') | net/quic/core/quic_connection.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 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/core/crypto/quic_crypto_server_config.h" 5 #include "net/quic/core/crypto/quic_crypto_server_config.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 params->channel_id = key.as_string(); 991 params->channel_id = key.as_string();
992 } 992 }
993 } 993 }
994 994
995 string hkdf_input; 995 string hkdf_input;
996 size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1; 996 size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1;
997 hkdf_input.reserve(label_len + hkdf_suffix.size()); 997 hkdf_input.reserve(label_len + hkdf_suffix.size());
998 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len); 998 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len);
999 hkdf_input.append(hkdf_suffix); 999 hkdf_input.append(hkdf_suffix);
1000 1000
1001 rand->RandBytes(out_diversification_nonce->data(),
1002 out_diversification_nonce->size());
1001 CryptoUtils::Diversification diversification = 1003 CryptoUtils::Diversification diversification =
1002 CryptoUtils::Diversification::Never(); 1004 CryptoUtils::Diversification::Now(out_diversification_nonce.get());
1003 if (version > QUIC_VERSION_32) {
1004 rand->RandBytes(out_diversification_nonce->data(),
1005 out_diversification_nonce->size());
1006 diversification =
1007 CryptoUtils::Diversification::Now(out_diversification_nonce.get());
1008 }
1009
1010 if (!CryptoUtils::DeriveKeys(params->initial_premaster_secret, params->aead, 1005 if (!CryptoUtils::DeriveKeys(params->initial_premaster_secret, params->aead,
1011 info.client_nonce, info.server_nonce, hkdf_input, 1006 info.client_nonce, info.server_nonce, hkdf_input,
1012 Perspective::IS_SERVER, diversification, 1007 Perspective::IS_SERVER, diversification,
1013 &params->initial_crypters, 1008 &params->initial_crypters,
1014 &params->initial_subkey_secret)) { 1009 &params->initial_subkey_secret)) {
1015 helper.Fail(QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED, 1010 helper.Fail(QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED,
1016 "Symmetric key setup failed"); 1011 "Symmetric key setup failed");
1017 return; 1012 return;
1018 } 1013 }
1019 1014
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 scoped_refptr<QuicSignedServerConfig> signed_config, 1378 scoped_refptr<QuicSignedServerConfig> signed_config,
1384 std::unique_ptr<ProofSource::Details> proof_source_details, 1379 std::unique_ptr<ProofSource::Details> proof_source_details,
1385 bool get_proof_failed, 1380 bool get_proof_failed,
1386 scoped_refptr<ValidateClientHelloResultCallback::Result> client_hello_state, 1381 scoped_refptr<ValidateClientHelloResultCallback::Result> client_hello_state,
1387 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const { 1382 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const {
1388 ValidateClientHelloHelper helper(client_hello_state, &done_cb); 1383 ValidateClientHelloHelper helper(client_hello_state, &done_cb);
1389 const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello; 1384 const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello;
1390 ClientHelloInfo* info = &(client_hello_state->info); 1385 ClientHelloInfo* info = &(client_hello_state->info);
1391 1386
1392 if (get_proof_failed) { 1387 if (get_proof_failed) {
1393 found_error = true;
1394 info->reject_reasons.push_back(SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE); 1388 info->reject_reasons.push_back(SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE);
1395 } 1389 }
1396 1390
1397 if (!ValidateExpectedLeafCertificate(client_hello, *signed_config)) { 1391 if (!ValidateExpectedLeafCertificate(client_hello, *signed_config)) {
1398 found_error = true;
1399 info->reject_reasons.push_back(INVALID_EXPECTED_LEAF_CERTIFICATE); 1392 info->reject_reasons.push_back(INVALID_EXPECTED_LEAF_CERTIFICATE);
1400 } 1393 }
1401 1394
1402 if (info->client_nonce.size() != kNonceSize) { 1395 if (info->client_nonce.size() != kNonceSize) {
1403 info->reject_reasons.push_back(CLIENT_NONCE_INVALID_FAILURE); 1396 info->reject_reasons.push_back(CLIENT_NONCE_INVALID_FAILURE);
1404 // Invalid client nonce. 1397 // Invalid client nonce.
1405 LOG(ERROR) << "Invalid client nonce: " << client_hello.DebugString(); 1398 LOG(ERROR) << "Invalid client nonce: " << client_hello.DebugString();
1406 DVLOG(1) << "Invalid client nonce."; 1399 DVLOG(1) << "Invalid client nonce.";
1407 found_error = true;
1408 } 1400 }
1409 1401
1410 // Server nonce is optional, and used for key derivation if present. 1402 // Server nonce is optional, and used for key derivation if present.
1411 client_hello.GetStringPiece(kServerNonceTag, &info->server_nonce); 1403 client_hello.GetStringPiece(kServerNonceTag, &info->server_nonce);
1412 1404
1413 if (version > QUIC_VERSION_32) { 1405 DVLOG(1) << "No 0-RTT replay protection in QUIC_VERSION_33 and higher.";
1414 DVLOG(1) << "No 0-RTT replay protection in QUIC_VERSION_33 and higher."; 1406 // If the server nonce is empty and we're requiring handshake confirmation
1415 // If the server nonce is empty and we're requiring handshake confirmation 1407 // for DoS reasons then we must reject the CHLO.
1416 // for DoS reasons then we must reject the CHLO. 1408 if (FLAGS_quic_require_handshake_confirmation && info->server_nonce.empty()) {
1417 if (FLAGS_quic_require_handshake_confirmation && 1409 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE);
1418 info->server_nonce.empty()) {
1419 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE);
1420 }
1421 helper.ValidationComplete(QUIC_NO_ERROR, "",
1422 std::move(proof_source_details));
1423 return;
1424 } 1410 }
1425 1411 helper.ValidationComplete(QUIC_NO_ERROR, "", std::move(proof_source_details));
1426 if (!replay_protection_) {
1427 DVLOG(1) << "No replay protection.";
1428 helper.ValidationComplete(QUIC_NO_ERROR, "",
1429 std::move(proof_source_details));
1430 return;
1431 }
1432
1433 if (!info->server_nonce.empty()) {
1434 // If the server nonce is present, use it to establish uniqueness.
1435 HandshakeFailureReason server_nonce_error =
1436 ValidateServerNonce(info->server_nonce, info->now);
1437 bool is_unique = server_nonce_error == HANDSHAKE_OK;
1438 if (!is_unique) {
1439 info->reject_reasons.push_back(server_nonce_error);
1440 }
1441 DVLOG(1) << "Using server nonce, unique: " << is_unique;
1442 helper.ValidationComplete(QUIC_NO_ERROR, "",
1443 std::move(proof_source_details));
1444 return;
1445 }
1446 // If we hit this block, the server nonce was empty. If we're requiring
1447 // handshake confirmation for DoS reasons and there's no server nonce present,
1448 // reject the CHLO.
1449 if (FLAGS_quic_require_handshake_confirmation ||
1450 FLAGS_quic_require_handshake_confirmation_pre33) {
1451 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE);
1452 helper.ValidationComplete(QUIC_NO_ERROR, "",
1453 std::move(proof_source_details));
1454 return;
1455 }
1456
1457 // We want to contact strike register only if there are no errors because it
1458 // is a RPC call and is expensive.
1459 if (found_error) {
1460 helper.ValidationComplete(QUIC_NO_ERROR, "",
1461 std::move(proof_source_details));
1462 return;
1463 }
1464
1465 // Use the client nonce to establish uniqueness.
1466 StrikeRegisterClient* strike_register_client;
1467 {
1468 base::AutoLock locked(strike_register_client_lock_);
1469 strike_register_client = strike_register_client_.get();
1470 }
1471
1472 if (!strike_register_client) {
1473 // Either a valid server nonces or a strike register is required.
1474 // Since neither are present, reject the handshake which will send a
1475 // server nonce to the client.
1476 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE);
1477 helper.ValidationComplete(QUIC_NO_ERROR, "",
1478 std::move(proof_source_details));
1479 return;
1480 }
1481
1482 strike_register_client->VerifyNonceIsValidAndUnique(
1483 info->client_nonce, info->now,
1484 new VerifyNonceIsValidAndUniqueCallback(client_hello_state,
1485 std::move(proof_source_details),
1486 std::move(done_cb)));
1487 helper.DetachCallback();
1488 } 1412 }
1489 1413
1490 bool QuicCryptoServerConfig::BuildServerConfigUpdateMessage( 1414 bool QuicCryptoServerConfig::BuildServerConfigUpdateMessage(
1491 QuicVersion version, 1415 QuicVersion version,
1492 StringPiece chlo_hash, 1416 StringPiece chlo_hash,
1493 const SourceAddressTokens& previous_source_address_tokens, 1417 const SourceAddressTokens& previous_source_address_tokens,
1494 const IPAddress& server_ip, 1418 const IPAddress& server_ip,
1495 const IPAddress& client_ip, 1419 const IPAddress& client_ip,
1496 const QuicClock* clock, 1420 const QuicClock* clock,
1497 QuicRandom* rand, 1421 QuicRandom* rand,
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 source_address_token_boxer(nullptr) {} 2202 source_address_token_boxer(nullptr) {}
2279 2203
2280 QuicCryptoServerConfig::Config::~Config() { 2204 QuicCryptoServerConfig::Config::~Config() {
2281 } 2205 }
2282 2206
2283 QuicSignedServerConfig::QuicSignedServerConfig() 2207 QuicSignedServerConfig::QuicSignedServerConfig()
2284 : send_expect_ct_header(false) {} 2208 : send_expect_ct_header(false) {}
2285 QuicSignedServerConfig::~QuicSignedServerConfig() {} 2209 QuicSignedServerConfig::~QuicSignedServerConfig() {}
2286 2210
2287 } // namespace net 2211 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/quic_crypto_client_config_test.cc ('k') | net/quic/core/quic_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698