| 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/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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 const IPEndPoint& client_address, | 560 const IPEndPoint& client_address, |
| 561 QuicVersion version, | 561 QuicVersion version, |
| 562 const QuicVersionVector& supported_versions, | 562 const QuicVersionVector& supported_versions, |
| 563 bool use_stateless_rejects, | 563 bool use_stateless_rejects, |
| 564 QuicConnectionId server_designated_connection_id, | 564 QuicConnectionId server_designated_connection_id, |
| 565 const QuicClock* clock, | 565 const QuicClock* clock, |
| 566 QuicRandom* rand, | 566 QuicRandom* rand, |
| 567 QuicCompressedCertsCache* compressed_certs_cache, | 567 QuicCompressedCertsCache* compressed_certs_cache, |
| 568 QuicCryptoNegotiatedParameters* params, | 568 QuicCryptoNegotiatedParameters* params, |
| 569 QuicCryptoProof* crypto_proof, | 569 QuicCryptoProof* crypto_proof, |
| 570 QuicByteCount total_framing_overhead, |
| 571 QuicByteCount chlo_packet_size, |
| 570 CryptoHandshakeMessage* out, | 572 CryptoHandshakeMessage* out, |
| 571 DiversificationNonce* out_diversification_nonce, | 573 DiversificationNonce* out_diversification_nonce, |
| 572 string* error_details) const { | 574 string* error_details) const { |
| 573 DCHECK(error_details); | 575 DCHECK(error_details); |
| 574 | 576 |
| 575 const CryptoHandshakeMessage& client_hello = | 577 const CryptoHandshakeMessage& client_hello = |
| 576 validate_chlo_result.client_hello; | 578 validate_chlo_result.client_hello; |
| 577 const ClientHelloInfo& info = validate_chlo_result.info; | 579 const ClientHelloInfo& info = validate_chlo_result.info; |
| 578 | 580 |
| 579 QuicErrorCode valid = CryptoUtils::ValidateClientHello( | 581 QuicErrorCode valid = CryptoUtils::ValidateClientHello( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 StringPiece cert_sct; | 636 StringPiece cert_sct; |
| 635 if (client_hello.GetStringPiece(kCertificateSCTTag, &cert_sct) && | 637 if (client_hello.GetStringPiece(kCertificateSCTTag, &cert_sct) && |
| 636 cert_sct.empty()) { | 638 cert_sct.empty()) { |
| 637 params->sct_supported_by_client = true; | 639 params->sct_supported_by_client = true; |
| 638 } | 640 } |
| 639 | 641 |
| 640 if (!info.reject_reasons.empty() || !requested_config.get()) { | 642 if (!info.reject_reasons.empty() || !requested_config.get()) { |
| 641 BuildRejection(version, *primary_config, client_hello, info, | 643 BuildRejection(version, *primary_config, client_hello, info, |
| 642 validate_chlo_result.cached_network_params, | 644 validate_chlo_result.cached_network_params, |
| 643 use_stateless_rejects, server_designated_connection_id, rand, | 645 use_stateless_rejects, server_designated_connection_id, rand, |
| 644 compressed_certs_cache, params, *crypto_proof, out); | 646 compressed_certs_cache, params, *crypto_proof, |
| 647 total_framing_overhead, chlo_packet_size, out); |
| 645 return QUIC_NO_ERROR; | 648 return QUIC_NO_ERROR; |
| 646 } | 649 } |
| 647 | 650 |
| 648 if (reject_only) { | 651 if (reject_only) { |
| 649 return QUIC_NO_ERROR; | 652 return QUIC_NO_ERROR; |
| 650 } | 653 } |
| 651 | 654 |
| 652 const QuicTag* their_aeads; | 655 const QuicTag* their_aeads; |
| 653 const QuicTag* their_key_exchanges; | 656 const QuicTag* their_key_exchanges; |
| 654 size_t num_their_aeads, num_their_key_exchanges; | 657 size_t num_their_aeads, num_their_key_exchanges; |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 const Config& config, | 1438 const Config& config, |
| 1436 const CryptoHandshakeMessage& client_hello, | 1439 const CryptoHandshakeMessage& client_hello, |
| 1437 const ClientHelloInfo& info, | 1440 const ClientHelloInfo& info, |
| 1438 const CachedNetworkParameters& cached_network_params, | 1441 const CachedNetworkParameters& cached_network_params, |
| 1439 bool use_stateless_rejects, | 1442 bool use_stateless_rejects, |
| 1440 QuicConnectionId server_designated_connection_id, | 1443 QuicConnectionId server_designated_connection_id, |
| 1441 QuicRandom* rand, | 1444 QuicRandom* rand, |
| 1442 QuicCompressedCertsCache* compressed_certs_cache, | 1445 QuicCompressedCertsCache* compressed_certs_cache, |
| 1443 QuicCryptoNegotiatedParameters* params, | 1446 QuicCryptoNegotiatedParameters* params, |
| 1444 const QuicCryptoProof& crypto_proof, | 1447 const QuicCryptoProof& crypto_proof, |
| 1448 QuicByteCount total_framing_overhead, |
| 1449 QuicByteCount chlo_packet_size, |
| 1445 CryptoHandshakeMessage* out) const { | 1450 CryptoHandshakeMessage* out) const { |
| 1446 if (FLAGS_enable_quic_stateless_reject_support && use_stateless_rejects) { | 1451 if (FLAGS_enable_quic_stateless_reject_support && use_stateless_rejects) { |
| 1447 DVLOG(1) << "QUIC Crypto server config returning stateless reject " | 1452 DVLOG(1) << "QUIC Crypto server config returning stateless reject " |
| 1448 << "with server-designated connection ID " | 1453 << "with server-designated connection ID " |
| 1449 << server_designated_connection_id; | 1454 << server_designated_connection_id; |
| 1450 out->set_tag(kSREJ); | 1455 out->set_tag(kSREJ); |
| 1451 out->SetValue(kRCID, server_designated_connection_id); | 1456 out->SetValue(kRCID, server_designated_connection_id); |
| 1452 } else { | 1457 } else { |
| 1453 out->set_tag(kREJ); | 1458 out->set_tag(kREJ); |
| 1454 } | 1459 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1479 StringPiece client_cached_cert_hashes; | 1484 StringPiece client_cached_cert_hashes; |
| 1480 if (client_hello.GetStringPiece(kCCRT, &client_cached_cert_hashes)) { | 1485 if (client_hello.GetStringPiece(kCCRT, &client_cached_cert_hashes)) { |
| 1481 params->client_cached_cert_hashes = client_cached_cert_hashes.as_string(); | 1486 params->client_cached_cert_hashes = client_cached_cert_hashes.as_string(); |
| 1482 } | 1487 } |
| 1483 | 1488 |
| 1484 const string compressed = | 1489 const string compressed = |
| 1485 CompressChain(compressed_certs_cache, crypto_proof.chain, | 1490 CompressChain(compressed_certs_cache, crypto_proof.chain, |
| 1486 params->client_common_set_hashes, | 1491 params->client_common_set_hashes, |
| 1487 params->client_cached_cert_hashes, config.common_cert_sets); | 1492 params->client_cached_cert_hashes, config.common_cert_sets); |
| 1488 | 1493 |
| 1494 DCHECK_GT(chlo_packet_size, client_hello.size()); |
| 1489 // kREJOverheadBytes is a very rough estimate of how much of a REJ | 1495 // kREJOverheadBytes is a very rough estimate of how much of a REJ |
| 1490 // message is taken up by things other than the certificates. | 1496 // message is taken up by things other than the certificates. |
| 1491 // STK: 56 bytes | 1497 // STK: 56 bytes |
| 1492 // SNO: 56 bytes | 1498 // SNO: 56 bytes |
| 1493 // SCFG | 1499 // SCFG |
| 1494 // SCID: 16 bytes | 1500 // SCID: 16 bytes |
| 1495 // PUBS: 38 bytes | 1501 // PUBS: 38 bytes |
| 1496 const size_t kREJOverheadBytes = 166; | 1502 const size_t kREJOverheadBytes = 166; |
| 1497 // max_unverified_size is the number of bytes that the certificate chain, | 1503 // max_unverified_size is the number of bytes that the certificate chain, |
| 1498 // signature, and (optionally) signed certificate timestamp can consume before | 1504 // signature, and (optionally) signed certificate timestamp can consume before |
| 1499 // we will demand a valid source-address token. | 1505 // we will demand a valid source-address token. |
| 1500 const size_t max_unverified_size = | 1506 const size_t old_max_unverified_size = |
| 1501 client_hello.size() * chlo_multiplier_ - kREJOverheadBytes; | 1507 client_hello.size() * chlo_multiplier_ - kREJOverheadBytes; |
| 1508 const size_t new_max_unverified_size = |
| 1509 chlo_multiplier_ * (chlo_packet_size - total_framing_overhead) - |
| 1510 kREJOverheadBytes; |
| 1511 const size_t max_unverified_size = FLAGS_quic_use_chlo_packet_size |
| 1512 ? new_max_unverified_size |
| 1513 : old_max_unverified_size; |
| 1502 static_assert(kClientHelloMinimumSize * kMultiplier >= kREJOverheadBytes, | 1514 static_assert(kClientHelloMinimumSize * kMultiplier >= kREJOverheadBytes, |
| 1503 "overhead calculation may underflow"); | 1515 "overhead calculation may underflow"); |
| 1504 bool should_return_sct = | 1516 bool should_return_sct = |
| 1505 params->sct_supported_by_client && enable_serving_sct_; | 1517 params->sct_supported_by_client && enable_serving_sct_; |
| 1506 const size_t sct_size = should_return_sct ? crypto_proof.cert_sct.size() : 0; | 1518 const size_t sct_size = should_return_sct ? crypto_proof.cert_sct.size() : 0; |
| 1507 if (info.valid_source_address_token || | 1519 if (info.valid_source_address_token || |
| 1508 crypto_proof.signature.size() + compressed.size() + sct_size < | 1520 crypto_proof.signature.size() + compressed.size() + sct_size < |
| 1509 max_unverified_size) { | 1521 max_unverified_size) { |
| 1510 out->SetStringPiece(kCertificateTag, compressed); | 1522 out->SetStringPiece(kCertificateTag, compressed); |
| 1511 out->SetStringPiece(kPROF, crypto_proof.signature); | 1523 out->SetStringPiece(kPROF, crypto_proof.signature); |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 priority(0), | 2049 priority(0), |
| 2038 source_address_token_boxer(nullptr) {} | 2050 source_address_token_boxer(nullptr) {} |
| 2039 | 2051 |
| 2040 QuicCryptoServerConfig::Config::~Config() { | 2052 QuicCryptoServerConfig::Config::~Config() { |
| 2041 STLDeleteElements(&key_exchanges); | 2053 STLDeleteElements(&key_exchanges); |
| 2042 } | 2054 } |
| 2043 | 2055 |
| 2044 QuicCryptoProof::QuicCryptoProof() {} | 2056 QuicCryptoProof::QuicCryptoProof() {} |
| 2045 QuicCryptoProof::~QuicCryptoProof() {} | 2057 QuicCryptoProof::~QuicCryptoProof() {} |
| 2046 } // namespace net | 2058 } // namespace net |
| OLD | NEW |