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_client_config.h" | 5 #include "net/quic/core/crypto/quic_crypto_client_config.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 i != certs.end(); ++i) { | 478 i != certs.end(); ++i) { |
479 hashes.push_back(QuicUtils::FNV1a_64_Hash(i->data(), i->size())); | 479 hashes.push_back(QuicUtils::FNV1a_64_Hash(i->data(), i->size())); |
480 } | 480 } |
481 out->SetVector(kCCRT, hashes); | 481 out->SetVector(kCCRT, hashes); |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 QuicErrorCode QuicCryptoClientConfig::FillClientHello( | 485 QuicErrorCode QuicCryptoClientConfig::FillClientHello( |
486 const QuicServerId& server_id, | 486 const QuicServerId& server_id, |
487 QuicConnectionId connection_id, | 487 QuicConnectionId connection_id, |
488 const QuicVersion actual_version, | |
489 const QuicVersion preferred_version, | 488 const QuicVersion preferred_version, |
490 const CachedState* cached, | 489 const CachedState* cached, |
491 QuicWallTime now, | 490 QuicWallTime now, |
492 QuicRandom* rand, | 491 QuicRandom* rand, |
493 const ChannelIDKey* channel_id_key, | 492 const ChannelIDKey* channel_id_key, |
494 scoped_refptr<QuicCryptoNegotiatedParameters> out_params, | 493 scoped_refptr<QuicCryptoNegotiatedParameters> out_params, |
495 CryptoHandshakeMessage* out, | 494 CryptoHandshakeMessage* out, |
496 string* error_details) const { | 495 string* error_details) const { |
497 DCHECK(error_details != nullptr); | 496 DCHECK(error_details != nullptr); |
498 | 497 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 out_params->hkdf_input_suffix.append(certs[0]); | 689 out_params->hkdf_input_suffix.append(certs[0]); |
691 | 690 |
692 string hkdf_input; | 691 string hkdf_input; |
693 const size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1; | 692 const size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1; |
694 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); | 693 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); |
695 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len); | 694 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len); |
696 hkdf_input.append(out_params->hkdf_input_suffix); | 695 hkdf_input.append(out_params->hkdf_input_suffix); |
697 | 696 |
698 string* subkey_secret = &out_params->initial_subkey_secret; | 697 string* subkey_secret = &out_params->initial_subkey_secret; |
699 | 698 |
700 // Only perform key diversification for QUIC versions 33 and later. | 699 if (!CryptoUtils::DeriveKeys( |
701 // TODO(rch): remove the |actual_version| argument to this method when | 700 out_params->initial_premaster_secret, out_params->aead, |
702 // QUIC_VERSION_32 is removed. | 701 out_params->client_nonce, out_params->server_nonce, hkdf_input, |
703 CryptoUtils::Diversification diversification = | 702 Perspective::IS_CLIENT, CryptoUtils::Diversification::Pending(), |
704 actual_version > QUIC_VERSION_32 ? CryptoUtils::Diversification::Pending() | 703 &out_params->initial_crypters, subkey_secret)) { |
705 : CryptoUtils::Diversification::Never(); | |
706 if (!CryptoUtils::DeriveKeys(out_params->initial_premaster_secret, | |
707 out_params->aead, out_params->client_nonce, | |
708 out_params->server_nonce, hkdf_input, | |
709 Perspective::IS_CLIENT, diversification, | |
710 &out_params->initial_crypters, subkey_secret)) { | |
711 *error_details = "Symmetric key setup failed"; | 704 *error_details = "Symmetric key setup failed"; |
712 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; | 705 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; |
713 } | 706 } |
714 | 707 |
715 return QUIC_NO_ERROR; | 708 return QUIC_NO_ERROR; |
716 } | 709 } |
717 | 710 |
718 QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig( | 711 QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig( |
719 const CryptoHandshakeMessage& message, | 712 const CryptoHandshakeMessage& message, |
720 QuicWallTime now, | 713 QuicWallTime now, |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 975 } |
983 | 976 |
984 // Update canonical version to point at the "most recent" entry. | 977 // Update canonical version to point at the "most recent" entry. |
985 canonical_server_map_[suffix_server_id] = server_id; | 978 canonical_server_map_[suffix_server_id] = server_id; |
986 | 979 |
987 server_state->InitializeFrom(*canonical_state); | 980 server_state->InitializeFrom(*canonical_state); |
988 return true; | 981 return true; |
989 } | 982 } |
990 | 983 |
991 } // namespace net | 984 } // namespace net |
OLD | NEW |