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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 612 |
613 if (validate_chlo_result.error_code != QUIC_NO_ERROR) { | 613 if (validate_chlo_result.error_code != QUIC_NO_ERROR) { |
614 *error_details = validate_chlo_result.error_details; | 614 *error_details = validate_chlo_result.error_details; |
615 return validate_chlo_result.error_code; | 615 return validate_chlo_result.error_code; |
616 } | 616 } |
617 | 617 |
618 out->Clear(); | 618 out->Clear(); |
619 | 619 |
620 if (!ClientDemandsX509Proof(client_hello) && FLAGS_quic_require_x509) { | 620 if (!ClientDemandsX509Proof(client_hello) && FLAGS_quic_require_x509) { |
621 *error_details = "Missing or invalid PDMD"; | 621 *error_details = "Missing or invalid PDMD"; |
622 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 622 return QUIC_UNSUPPORTED_PROOF_DEMAND; |
623 } | 623 } |
624 DCHECK(proof_source_.get()); | 624 DCHECK(proof_source_.get()); |
625 string chlo_hash; | 625 string chlo_hash; |
626 CryptoUtils::HashHandshakeMessage(client_hello, &chlo_hash); | 626 CryptoUtils::HashHandshakeMessage(client_hello, &chlo_hash); |
627 // No need to get a new proof if one was already generated. | 627 // No need to get a new proof if one was already generated. |
628 if (!crypto_proof->chain && | 628 if (!crypto_proof->chain && |
629 !proof_source_->GetProof(server_ip, info.sni.as_string(), | 629 !proof_source_->GetProof(server_ip, info.sni.as_string(), |
630 primary_config->serialized, version, chlo_hash, | 630 primary_config->serialized, version, chlo_hash, |
631 &crypto_proof->chain, &crypto_proof->signature, | 631 &crypto_proof->chain, &crypto_proof->signature, |
632 &crypto_proof->cert_sct)) { | 632 &crypto_proof->cert_sct)) { |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 chlo_multiplier_ * (chlo_packet_size - total_framing_overhead) - | 1509 chlo_multiplier_ * (chlo_packet_size - total_framing_overhead) - |
1510 kREJOverheadBytes; | 1510 kREJOverheadBytes; |
1511 const size_t max_unverified_size = FLAGS_quic_use_chlo_packet_size | 1511 const size_t max_unverified_size = FLAGS_quic_use_chlo_packet_size |
1512 ? new_max_unverified_size | 1512 ? new_max_unverified_size |
1513 : old_max_unverified_size; | 1513 : old_max_unverified_size; |
1514 static_assert(kClientHelloMinimumSize * kMultiplier >= kREJOverheadBytes, | 1514 static_assert(kClientHelloMinimumSize * kMultiplier >= kREJOverheadBytes, |
1515 "overhead calculation may underflow"); | 1515 "overhead calculation may underflow"); |
1516 bool should_return_sct = | 1516 bool should_return_sct = |
1517 params->sct_supported_by_client && enable_serving_sct_; | 1517 params->sct_supported_by_client && enable_serving_sct_; |
1518 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; |
1519 if (info.valid_source_address_token || | 1519 const size_t total_size = |
1520 crypto_proof.signature.size() + compressed.size() + sct_size < | 1520 crypto_proof.signature.size() + compressed.size() + sct_size; |
1521 max_unverified_size) { | 1521 if (info.valid_source_address_token || total_size < max_unverified_size) { |
1522 out->SetStringPiece(kCertificateTag, compressed); | 1522 out->SetStringPiece(kCertificateTag, compressed); |
1523 out->SetStringPiece(kPROF, crypto_proof.signature); | 1523 out->SetStringPiece(kPROF, crypto_proof.signature); |
1524 if (should_return_sct) { | 1524 if (should_return_sct) { |
1525 if (crypto_proof.cert_sct.empty()) { | 1525 if (crypto_proof.cert_sct.empty()) { |
1526 DLOG(WARNING) << "SCT is expected but it is empty."; | 1526 DLOG(WARNING) << "SCT is expected but it is empty."; |
1527 } else { | 1527 } else { |
1528 out->SetStringPiece(kCertificateSCTTag, crypto_proof.cert_sct); | 1528 out->SetStringPiece(kCertificateSCTTag, crypto_proof.cert_sct); |
1529 } | 1529 } |
1530 } | 1530 } |
| 1531 } else { |
| 1532 if (FLAGS_quic_use_chlo_packet_size) { |
| 1533 DLOG(WARNING) << "Sending inchoate REJ for hostname: " << info.sni |
| 1534 << " signature: " << crypto_proof.signature.size() |
| 1535 << " cert: " << compressed.size() << " sct:" << sct_size |
| 1536 << " total: " << total_size |
| 1537 << " max: " << max_unverified_size; |
| 1538 } |
1531 } | 1539 } |
1532 } | 1540 } |
1533 | 1541 |
1534 string QuicCryptoServerConfig::CompressChain( | 1542 string QuicCryptoServerConfig::CompressChain( |
1535 QuicCompressedCertsCache* compressed_certs_cache, | 1543 QuicCompressedCertsCache* compressed_certs_cache, |
1536 const scoped_refptr<ProofSource::Chain>& chain, | 1544 const scoped_refptr<ProofSource::Chain>& chain, |
1537 const string& client_common_set_hashes, | 1545 const string& client_common_set_hashes, |
1538 const string& client_cached_cert_hashes, | 1546 const string& client_cached_cert_hashes, |
1539 const CommonCertSets* common_sets) { | 1547 const CommonCertSets* common_sets) { |
1540 // Check whether the compressed certs is available in the cache. | 1548 // Check whether the compressed certs is available in the cache. |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 priority(0), | 2057 priority(0), |
2050 source_address_token_boxer(nullptr) {} | 2058 source_address_token_boxer(nullptr) {} |
2051 | 2059 |
2052 QuicCryptoServerConfig::Config::~Config() { | 2060 QuicCryptoServerConfig::Config::~Config() { |
2053 base::STLDeleteElements(&key_exchanges); | 2061 base::STLDeleteElements(&key_exchanges); |
2054 } | 2062 } |
2055 | 2063 |
2056 QuicCryptoProof::QuicCryptoProof() {} | 2064 QuicCryptoProof::QuicCryptoProof() {} |
2057 QuicCryptoProof::~QuicCryptoProof() {} | 2065 QuicCryptoProof::~QuicCryptoProof() {} |
2058 } // namespace net | 2066 } // namespace net |
OLD | NEW |