| 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> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "crypto/hkdf.h" | 13 #include "crypto/hkdf.h" |
| 14 #include "crypto/secure_hash.h" | |
| 15 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h" | 14 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h" |
| 16 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" | 15 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" |
| 17 #include "net/quic/core/crypto/cert_compressor.h" | 16 #include "net/quic/core/crypto/cert_compressor.h" |
| 18 #include "net/quic/core/crypto/chacha20_poly1305_encrypter.h" | 17 #include "net/quic/core/crypto/chacha20_poly1305_encrypter.h" |
| 19 #include "net/quic/core/crypto/channel_id.h" | 18 #include "net/quic/core/crypto/channel_id.h" |
| 20 #include "net/quic/core/crypto/crypto_framer.h" | 19 #include "net/quic/core/crypto/crypto_framer.h" |
| 21 #include "net/quic/core/crypto/crypto_handshake_message.h" | 20 #include "net/quic/core/crypto/crypto_handshake_message.h" |
| 22 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" | 21 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" |
| 23 #include "net/quic/core/crypto/crypto_utils.h" | 22 #include "net/quic/core/crypto/crypto_utils.h" |
| 24 #include "net/quic/core/crypto/curve25519_key_exchange.h" | 23 #include "net/quic/core/crypto/curve25519_key_exchange.h" |
| 25 #include "net/quic/core/crypto/ephemeral_key_source.h" | 24 #include "net/quic/core/crypto/ephemeral_key_source.h" |
| 26 #include "net/quic/core/crypto/key_exchange.h" | 25 #include "net/quic/core/crypto/key_exchange.h" |
| 27 #include "net/quic/core/crypto/p256_key_exchange.h" | 26 #include "net/quic/core/crypto/p256_key_exchange.h" |
| 28 #include "net/quic/core/crypto/proof_source.h" | 27 #include "net/quic/core/crypto/proof_source.h" |
| 29 #include "net/quic/core/crypto/quic_decrypter.h" | 28 #include "net/quic/core/crypto/quic_decrypter.h" |
| 30 #include "net/quic/core/crypto/quic_encrypter.h" | 29 #include "net/quic/core/crypto/quic_encrypter.h" |
| 31 #include "net/quic/core/crypto/quic_random.h" | 30 #include "net/quic/core/crypto/quic_random.h" |
| 32 #include "net/quic/core/proto/source_address_token.pb.h" | 31 #include "net/quic/core/proto/source_address_token.pb.h" |
| 33 #include "net/quic/core/quic_flags.h" | 32 #include "net/quic/core/quic_flags.h" |
| 34 #include "net/quic/core/quic_packets.h" | 33 #include "net/quic/core/quic_packets.h" |
| 35 #include "net/quic/core/quic_socket_address_coder.h" | 34 #include "net/quic/core/quic_socket_address_coder.h" |
| 36 #include "net/quic/core/quic_utils.h" | 35 #include "net/quic/core/quic_utils.h" |
| 37 #include "net/quic/platform/api/quic_bug_tracker.h" | 36 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 38 #include "net/quic/platform/api/quic_clock.h" | 37 #include "net/quic/platform/api/quic_clock.h" |
| 39 #include "net/quic/platform/api/quic_logging.h" | 38 #include "net/quic/platform/api/quic_logging.h" |
| 40 #include "net/quic/platform/api/quic_reference_counted.h" | 39 #include "net/quic/platform/api/quic_reference_counted.h" |
| 41 #include "net/quic/platform/api/quic_text_utils.h" | 40 #include "net/quic/platform/api/quic_text_utils.h" |
| 42 #include "net/quic/platform/api/quic_url_utils.h" | 41 #include "net/quic/platform/api/quic_url_utils.h" |
| 42 #include "third_party/boringssl/src/include/openssl/sha.h" |
| 43 | 43 |
| 44 using base::StringPiece; | 44 using base::StringPiece; |
| 45 using std::string; | 45 using std::string; |
| 46 | 46 |
| 47 namespace net { | 47 namespace net { |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 // kMultiplier is the multiple of the CHLO message size that a REJ message | 51 // kMultiplier is the multiple of the CHLO message size that a REJ message |
| 52 // must stay under when the client doesn't present a valid source-address | 52 // must stay under when the client doesn't present a valid source-address |
| 53 // token. This is used to protect QUIC from amplification attacks. | 53 // token. This is used to protect QUIC from amplification attacks. |
| 54 // TODO(rch): Reduce this to 2 again once b/25933682 is fixed. | 54 // TODO(rch): Reduce this to 2 again once b/25933682 is fixed. |
| 55 const size_t kMultiplier = 3; | 55 const size_t kMultiplier = 3; |
| 56 | 56 |
| 57 const int kMaxTokenAddresses = 4; | 57 const int kMaxTokenAddresses = 4; |
| 58 | 58 |
| 59 string DeriveSourceAddressTokenKey(StringPiece source_address_token_secret) { | 59 string DeriveSourceAddressTokenKey(StringPiece source_address_token_secret) { |
| 60 crypto::HKDF hkdf(source_address_token_secret, StringPiece() /* no salt */, | 60 crypto::HKDF hkdf(source_address_token_secret, StringPiece() /* no salt */, |
| 61 "QUIC source address token key", | 61 "QUIC source address token key", |
| 62 CryptoSecretBoxer::GetKeySize(), 0 /* no fixed IV needed */, | 62 CryptoSecretBoxer::GetKeySize(), 0 /* no fixed IV needed */, |
| 63 0 /* no subkey secret */); | 63 0 /* no subkey secret */); |
| 64 return hkdf.server_write_key().as_string(); | 64 return hkdf.server_write_key().as_string(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 using crypto::SecureHash; | |
| 70 | |
| 71 class ValidateClientHelloHelper { | 69 class ValidateClientHelloHelper { |
| 72 public: | 70 public: |
| 73 // Note: stores a pointer to a unique_ptr, and std::moves the unique_ptr when | 71 // Note: stores a pointer to a unique_ptr, and std::moves the unique_ptr when |
| 74 // ValidationComplete is called. | 72 // ValidationComplete is called. |
| 75 ValidateClientHelloHelper( | 73 ValidateClientHelloHelper( |
| 76 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> | 74 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> |
| 77 result, | 75 result, |
| 78 std::unique_ptr<ValidateClientHelloResultCallback>* done_cb) | 76 std::unique_ptr<ValidateClientHelloResultCallback>* done_cb) |
| 79 : result_(std::move(result)), done_cb_(done_cb) {} | 77 : result_(std::move(result)), done_cb_(done_cb) {} |
| 80 | 78 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 255 |
| 258 if (!options.token_binding_params.empty()) { | 256 if (!options.token_binding_params.empty()) { |
| 259 msg.SetVector(kTBKP, options.token_binding_params); | 257 msg.SetVector(kTBKP, options.token_binding_params); |
| 260 } | 258 } |
| 261 | 259 |
| 262 if (options.id.empty()) { | 260 if (options.id.empty()) { |
| 263 // We need to ensure that the SCID changes whenever the server config does | 261 // We need to ensure that the SCID changes whenever the server config does |
| 264 // thus we make it a hash of the rest of the server config. | 262 // thus we make it a hash of the rest of the server config. |
| 265 std::unique_ptr<QuicData> serialized( | 263 std::unique_ptr<QuicData> serialized( |
| 266 CryptoFramer::ConstructHandshakeMessage(msg)); | 264 CryptoFramer::ConstructHandshakeMessage(msg)); |
| 267 std::unique_ptr<SecureHash> hash(SecureHash::Create(SecureHash::SHA256)); | |
| 268 hash->Update(serialized->data(), serialized->length()); | |
| 269 | 265 |
| 270 char scid_bytes[16]; | 266 uint8_t scid_bytes[SHA256_DIGEST_LENGTH]; |
| 271 hash->Finish(scid_bytes, sizeof(scid_bytes)); | 267 SHA256(reinterpret_cast<const uint8_t*>(serialized->data()), |
| 272 msg.SetStringPiece(kSCID, StringPiece(scid_bytes, sizeof(scid_bytes))); | 268 serialized->length(), scid_bytes); |
| 269 // The SCID is a truncated SHA-256 digest. |
| 270 static_assert(16 <= SHA256_DIGEST_LENGTH, "SCID length too high."); |
| 271 msg.SetStringPiece( |
| 272 kSCID, StringPiece(reinterpret_cast<const char*>(scid_bytes), 16)); |
| 273 } else { | 273 } else { |
| 274 msg.SetStringPiece(kSCID, options.id); | 274 msg.SetStringPiece(kSCID, options.id); |
| 275 } | 275 } |
| 276 // Don't put new tags below this point. The SCID generation should hash over | 276 // Don't put new tags below this point. The SCID generation should hash over |
| 277 // everything but itself and so extra tags should be added prior to the | 277 // everything but itself and so extra tags should be added prior to the |
| 278 // preceding if block. | 278 // preceding if block. |
| 279 | 279 |
| 280 std::unique_ptr<QuicData> serialized( | 280 std::unique_ptr<QuicData> serialized( |
| 281 CryptoFramer::ConstructHandshakeMessage(msg)); | 281 CryptoFramer::ConstructHandshakeMessage(msg)); |
| 282 | 282 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 CryptoUtils::HashHandshakeMessage(client_hello, &chlo_hash); | 691 CryptoUtils::HashHandshakeMessage(client_hello, &chlo_hash); |
| 692 | 692 |
| 693 // No need to get a new proof if one was already generated. | 693 // No need to get a new proof if one was already generated. |
| 694 if (!signed_config->chain) { | 694 if (!signed_config->chain) { |
| 695 const QuicTag* tag_ptr; | 695 const QuicTag* tag_ptr; |
| 696 size_t num_tags; | 696 size_t num_tags; |
| 697 QuicTagVector connection_options; | 697 QuicTagVector connection_options; |
| 698 if (client_hello.GetTaglist(kCOPT, &tag_ptr, &num_tags) == QUIC_NO_ERROR) { | 698 if (client_hello.GetTaglist(kCOPT, &tag_ptr, &num_tags) == QUIC_NO_ERROR) { |
| 699 connection_options.assign(tag_ptr, tag_ptr + num_tags); | 699 connection_options.assign(tag_ptr, tag_ptr + num_tags); |
| 700 } | 700 } |
| 701 if (FLAGS_quic_reloadable_flag_enable_async_get_proof) { | 701 std::unique_ptr<ProcessClientHelloCallback> cb( |
| 702 std::unique_ptr<ProcessClientHelloCallback> cb( | 702 new ProcessClientHelloCallback( |
| 703 new ProcessClientHelloCallback( | 703 this, validate_chlo_result, reject_only, connection_id, |
| 704 this, validate_chlo_result, reject_only, connection_id, | 704 client_address, version, supported_versions, use_stateless_rejects, |
| 705 client_address, version, supported_versions, | 705 server_designated_connection_id, clock, rand, |
| 706 use_stateless_rejects, server_designated_connection_id, clock, | 706 compressed_certs_cache, params, signed_config, |
| 707 rand, compressed_certs_cache, params, signed_config, | 707 total_framing_overhead, chlo_packet_size, requested_config, |
| 708 total_framing_overhead, chlo_packet_size, requested_config, | 708 primary_config, std::move(done_cb))); |
| 709 primary_config, std::move(done_cb))); | 709 proof_source_->GetProof(server_address, info.sni.as_string(), |
| 710 proof_source_->GetProof(server_address, info.sni.as_string(), | 710 primary_config->serialized, version, chlo_hash, |
| 711 primary_config->serialized, version, chlo_hash, | 711 connection_options, std::move(cb)); |
| 712 connection_options, std::move(cb)); | 712 helper.DetachCallback(); |
| 713 helper.DetachCallback(); | 713 return; |
| 714 return; | |
| 715 } | |
| 716 | |
| 717 QuicCryptoProof proof; | |
| 718 if (!proof_source_->GetProof(server_address, info.sni.as_string(), | |
| 719 primary_config->serialized, version, chlo_hash, | |
| 720 connection_options, &signed_config->chain, | |
| 721 &proof)) { | |
| 722 helper.Fail(QUIC_HANDSHAKE_FAILED, "Missing or invalid crypto proof."); | |
| 723 return; | |
| 724 } | |
| 725 signed_config->proof = proof; | |
| 726 } | 714 } |
| 727 | 715 |
| 728 helper.DetachCallback(); | 716 helper.DetachCallback(); |
| 729 ProcessClientHelloAfterGetProof( | 717 ProcessClientHelloAfterGetProof( |
| 730 /* found_error = */ false, /* proof_source_details = */ nullptr, | 718 /* found_error = */ false, /* proof_source_details = */ nullptr, |
| 731 *validate_chlo_result, reject_only, connection_id, client_address, | 719 *validate_chlo_result, reject_only, connection_id, client_address, |
| 732 version, supported_versions, use_stateless_rejects, | 720 version, supported_versions, use_stateless_rejects, |
| 733 server_designated_connection_id, clock, rand, compressed_certs_cache, | 721 server_designated_connection_id, clock, rand, compressed_certs_cache, |
| 734 params, signed_config, total_framing_overhead, chlo_packet_size, | 722 params, signed_config, total_framing_overhead, chlo_packet_size, |
| 735 requested_config, primary_config, std::move(done_cb)); | 723 requested_config, primary_config, std::move(done_cb)); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 CryptoUtils::Diversification::Never(), | 888 CryptoUtils::Diversification::Never(), |
| 901 &crypters, nullptr /* subkey secret */)) { | 889 &crypters, nullptr /* subkey secret */)) { |
| 902 helper.Fail(QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED, | 890 helper.Fail(QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED, |
| 903 "Symmetric key setup failed"); | 891 "Symmetric key setup failed"); |
| 904 return; | 892 return; |
| 905 } | 893 } |
| 906 | 894 |
| 907 char plaintext[kMaxPacketSize]; | 895 char plaintext[kMaxPacketSize]; |
| 908 size_t plaintext_length = 0; | 896 size_t plaintext_length = 0; |
| 909 const bool success = crypters.decrypter->DecryptPacket( | 897 const bool success = crypters.decrypter->DecryptPacket( |
| 910 QUIC_VERSION_35, kDefaultPathId, 0 /* packet number */, | 898 QUIC_VERSION_35, 0 /* packet number */, |
| 911 StringPiece() /* associated data */, cetv_ciphertext, plaintext, | 899 StringPiece() /* associated data */, cetv_ciphertext, plaintext, |
| 912 &plaintext_length, kMaxPacketSize); | 900 &plaintext_length, kMaxPacketSize); |
| 913 if (!success) { | 901 if (!success) { |
| 914 helper.Fail(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, | 902 helper.Fail(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, |
| 915 "CETV decryption failure"); | 903 "CETV decryption failure"); |
| 916 return; | 904 return; |
| 917 } | 905 } |
| 918 std::unique_ptr<CryptoHandshakeMessage> cetv( | 906 std::unique_ptr<CryptoHandshakeMessage> cetv( |
| 919 CryptoFramer::ParseMessage(StringPiece(plaintext, plaintext_length))); | 907 CryptoFramer::ParseMessage(StringPiece(plaintext, plaintext_length))); |
| 920 if (!cetv.get()) { | 908 if (!cetv.get()) { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 string chlo_hash; | 1256 string chlo_hash; |
| 1269 CryptoUtils::HashHandshakeMessage(client_hello, &chlo_hash); | 1257 CryptoUtils::HashHandshakeMessage(client_hello, &chlo_hash); |
| 1270 bool need_proof = true; | 1258 bool need_proof = true; |
| 1271 need_proof = !signed_config->chain; | 1259 need_proof = !signed_config->chain; |
| 1272 const QuicTag* tag_ptr; | 1260 const QuicTag* tag_ptr; |
| 1273 size_t num_tags; | 1261 size_t num_tags; |
| 1274 QuicTagVector connection_options; | 1262 QuicTagVector connection_options; |
| 1275 if (client_hello.GetTaglist(kCOPT, &tag_ptr, &num_tags) == QUIC_NO_ERROR) { | 1263 if (client_hello.GetTaglist(kCOPT, &tag_ptr, &num_tags) == QUIC_NO_ERROR) { |
| 1276 connection_options.assign(tag_ptr, tag_ptr + num_tags); | 1264 connection_options.assign(tag_ptr, tag_ptr + num_tags); |
| 1277 } | 1265 } |
| 1278 if (FLAGS_quic_reloadable_flag_enable_async_get_proof) { | |
| 1279 if (need_proof) { | |
| 1280 // Make an async call to GetProof and setup the callback to trampoline | |
| 1281 // back into EvaluateClientHelloAfterGetProof | |
| 1282 std::unique_ptr<EvaluateClientHelloCallback> cb( | |
| 1283 new EvaluateClientHelloCallback( | |
| 1284 *this, found_error, server_address.host(), version, | |
| 1285 requested_config, primary_config, signed_config, | |
| 1286 client_hello_state, std::move(done_cb))); | |
| 1287 proof_source_->GetProof(server_address, info->sni.as_string(), | |
| 1288 serialized_config, version, chlo_hash, | |
| 1289 connection_options, std::move(cb)); | |
| 1290 helper.DetachCallback(); | |
| 1291 return; | |
| 1292 } | |
| 1293 } | |
| 1294 | 1266 |
| 1295 // No need to get a new proof if one was already generated. | |
| 1296 if (need_proof) { | 1267 if (need_proof) { |
| 1297 QuicCryptoProof proof; | 1268 // Make an async call to GetProof and setup the callback to trampoline |
| 1298 | 1269 // back into EvaluateClientHelloAfterGetProof |
| 1299 if (proof_source_->GetProof( | 1270 std::unique_ptr<EvaluateClientHelloCallback> cb( |
| 1300 server_address, info->sni.as_string(), serialized_config, version, | 1271 new EvaluateClientHelloCallback( |
| 1301 chlo_hash, connection_options, &signed_config->chain, &proof)) { | 1272 *this, found_error, server_address.host(), version, |
| 1302 signed_config->proof = proof; | 1273 requested_config, primary_config, signed_config, client_hello_state, |
| 1303 } else { | 1274 std::move(done_cb))); |
| 1304 get_proof_failed = true; | 1275 proof_source_->GetProof(server_address, info->sni.as_string(), |
| 1305 } | 1276 serialized_config, version, chlo_hash, |
| 1277 connection_options, std::move(cb)); |
| 1278 helper.DetachCallback(); |
| 1279 return; |
| 1306 } | 1280 } |
| 1307 | 1281 |
| 1308 // Details are null because the synchronous version of GetProof does not | 1282 // Details are null because the synchronous version of GetProof does not |
| 1309 // return any stats. Eventually the synchronous codepath will be eliminated. | 1283 // return any stats. Eventually the synchronous codepath will be eliminated. |
| 1310 EvaluateClientHelloAfterGetProof( | 1284 EvaluateClientHelloAfterGetProof( |
| 1311 found_error, server_address.host(), version, requested_config, | 1285 found_error, server_address.host(), version, requested_config, |
| 1312 primary_config, signed_config, nullptr /* proof_source_details */, | 1286 primary_config, signed_config, nullptr /* proof_source_details */, |
| 1313 get_proof_failed, client_hello_state, std::move(done_cb)); | 1287 get_proof_failed, client_hello_state, std::move(done_cb)); |
| 1314 helper.DetachCallback(); | 1288 helper.DetachCallback(); |
| 1315 } | 1289 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 QUIC_DVLOG(1) << "No 0-RTT replay protection in QUIC_VERSION_33 and higher."; | 1328 QUIC_DVLOG(1) << "No 0-RTT replay protection in QUIC_VERSION_33 and higher."; |
| 1355 // If the server nonce is empty and we're requiring handshake confirmation | 1329 // If the server nonce is empty and we're requiring handshake confirmation |
| 1356 // for DoS reasons then we must reject the CHLO. | 1330 // for DoS reasons then we must reject the CHLO. |
| 1357 if (FLAGS_quic_reloadable_flag_quic_require_handshake_confirmation && | 1331 if (FLAGS_quic_reloadable_flag_quic_require_handshake_confirmation && |
| 1358 info->server_nonce.empty()) { | 1332 info->server_nonce.empty()) { |
| 1359 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); | 1333 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); |
| 1360 } | 1334 } |
| 1361 helper.ValidationComplete(QUIC_NO_ERROR, "", std::move(proof_source_details)); | 1335 helper.ValidationComplete(QUIC_NO_ERROR, "", std::move(proof_source_details)); |
| 1362 } | 1336 } |
| 1363 | 1337 |
| 1364 bool QuicCryptoServerConfig::BuildServerConfigUpdateMessage( | |
| 1365 QuicVersion version, | |
| 1366 StringPiece chlo_hash, | |
| 1367 const SourceAddressTokens& previous_source_address_tokens, | |
| 1368 const QuicSocketAddress& server_address, | |
| 1369 const QuicIpAddress& client_ip, | |
| 1370 const QuicClock* clock, | |
| 1371 QuicRandom* rand, | |
| 1372 QuicCompressedCertsCache* compressed_certs_cache, | |
| 1373 const QuicCryptoNegotiatedParameters& params, | |
| 1374 const CachedNetworkParameters* cached_network_params, | |
| 1375 const QuicTagVector& connection_options, | |
| 1376 CryptoHandshakeMessage* out) const { | |
| 1377 string serialized; | |
| 1378 string source_address_token; | |
| 1379 QuicWallTime expiry_time = QuicWallTime::Zero(); | |
| 1380 const CommonCertSets* common_cert_sets; | |
| 1381 { | |
| 1382 QuicReaderMutexLock locked(&configs_lock_); | |
| 1383 serialized = primary_config_->serialized; | |
| 1384 common_cert_sets = primary_config_->common_cert_sets; | |
| 1385 expiry_time = primary_config_->expiry_time; | |
| 1386 source_address_token = NewSourceAddressToken( | |
| 1387 *primary_config_, previous_source_address_tokens, client_ip, rand, | |
| 1388 clock->WallNow(), cached_network_params); | |
| 1389 } | |
| 1390 | |
| 1391 out->set_tag(kSCUP); | |
| 1392 out->SetStringPiece(kSCFG, serialized); | |
| 1393 out->SetStringPiece(kSourceAddressTokenTag, source_address_token); | |
| 1394 out->SetValue(kSTTL, | |
| 1395 expiry_time.AbsoluteDifference(clock->WallNow()).ToSeconds()); | |
| 1396 | |
| 1397 QuicReferenceCountedPointer<ProofSource::Chain> chain; | |
| 1398 QuicCryptoProof proof; | |
| 1399 if (!proof_source_->GetProof(server_address, params.sni, serialized, version, | |
| 1400 chlo_hash, connection_options, &chain, &proof)) { | |
| 1401 QUIC_DVLOG(1) << "Server: failed to get proof."; | |
| 1402 return false; | |
| 1403 } | |
| 1404 | |
| 1405 const string compressed = CompressChain( | |
| 1406 compressed_certs_cache, chain, params.client_common_set_hashes, | |
| 1407 params.client_cached_cert_hashes, common_cert_sets); | |
| 1408 | |
| 1409 out->SetStringPiece(kCertificateTag, compressed); | |
| 1410 out->SetStringPiece(kPROF, proof.signature); | |
| 1411 if (params.sct_supported_by_client && enable_serving_sct_) { | |
| 1412 if (proof.leaf_cert_scts.empty()) { | |
| 1413 QUIC_LOG_EVERY_N_SEC(WARNING, 60) | |
| 1414 << "SCT is expected but it is empty. sni: " << params.sni | |
| 1415 << " server_address: " << server_address.ToString(); | |
| 1416 } else { | |
| 1417 out->SetStringPiece(kCertificateSCTTag, proof.leaf_cert_scts); | |
| 1418 } | |
| 1419 } | |
| 1420 return true; | |
| 1421 } | |
| 1422 | |
| 1423 void QuicCryptoServerConfig::BuildServerConfigUpdateMessage( | 1338 void QuicCryptoServerConfig::BuildServerConfigUpdateMessage( |
| 1424 QuicVersion version, | 1339 QuicVersion version, |
| 1425 StringPiece chlo_hash, | 1340 StringPiece chlo_hash, |
| 1426 const SourceAddressTokens& previous_source_address_tokens, | 1341 const SourceAddressTokens& previous_source_address_tokens, |
| 1427 const QuicSocketAddress& server_address, | 1342 const QuicSocketAddress& server_address, |
| 1428 const QuicIpAddress& client_ip, | 1343 const QuicIpAddress& client_ip, |
| 1429 const QuicClock* clock, | 1344 const QuicClock* clock, |
| 1430 QuicRandom* rand, | 1345 QuicRandom* rand, |
| 1431 QuicCompressedCertsCache* compressed_certs_cache, | 1346 QuicCompressedCertsCache* compressed_certs_cache, |
| 1432 const QuicCryptoNegotiatedParameters& params, | 1347 const QuicCryptoNegotiatedParameters& params, |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 expiry_time(QuicWallTime::Zero()), | 1951 expiry_time(QuicWallTime::Zero()), |
| 2037 priority(0), | 1952 priority(0), |
| 2038 source_address_token_boxer(nullptr) {} | 1953 source_address_token_boxer(nullptr) {} |
| 2039 | 1954 |
| 2040 QuicCryptoServerConfig::Config::~Config() {} | 1955 QuicCryptoServerConfig::Config::~Config() {} |
| 2041 | 1956 |
| 2042 QuicSignedServerConfig::QuicSignedServerConfig() {} | 1957 QuicSignedServerConfig::QuicSignedServerConfig() {} |
| 2043 QuicSignedServerConfig::~QuicSignedServerConfig() {} | 1958 QuicSignedServerConfig::~QuicSignedServerConfig() {} |
| 2044 | 1959 |
| 2045 } // namespace net | 1960 } // namespace net |
| OLD | NEW |