| 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/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return QUIC_INVALID_CHANNEL_ID_SIGNATURE; | 505 return QUIC_INVALID_CHANNEL_ID_SIGNATURE; |
| 506 } | 506 } |
| 507 | 507 |
| 508 cetv.SetStringPiece(kCIDK, key); | 508 cetv.SetStringPiece(kCIDK, key); |
| 509 cetv.SetStringPiece(kCIDS, signature); | 509 cetv.SetStringPiece(kCIDS, signature); |
| 510 | 510 |
| 511 CrypterPair crypters; | 511 CrypterPair crypters; |
| 512 if (!CryptoUtils::DeriveKeys(out_params->initial_premaster_secret, | 512 if (!CryptoUtils::DeriveKeys(out_params->initial_premaster_secret, |
| 513 out_params->aead, out_params->client_nonce, | 513 out_params->aead, out_params->client_nonce, |
| 514 out_params->server_nonce, hkdf_input, | 514 out_params->server_nonce, hkdf_input, |
| 515 CryptoUtils::CLIENT, &crypters)) { | 515 CryptoUtils::CLIENT, &crypters, |
| 516 NULL /* subkey secret */)) { |
| 516 *error_details = "Symmetric key setup failed"; | 517 *error_details = "Symmetric key setup failed"; |
| 517 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; | 518 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; |
| 518 } | 519 } |
| 519 | 520 |
| 520 const QuicData& cetv_plaintext = cetv.GetSerialized(); | 521 const QuicData& cetv_plaintext = cetv.GetSerialized(); |
| 521 scoped_ptr<QuicData> cetv_ciphertext(crypters.encrypter->EncryptPacket( | 522 scoped_ptr<QuicData> cetv_ciphertext(crypters.encrypter->EncryptPacket( |
| 522 0 /* sequence number */, | 523 0 /* sequence number */, |
| 523 StringPiece() /* associated data */, | 524 StringPiece() /* associated data */, |
| 524 cetv_plaintext.AsStringPiece())); | 525 cetv_plaintext.AsStringPiece())); |
| 525 if (!cetv_ciphertext.get()) { | 526 if (!cetv_ciphertext.get()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 547 | 548 |
| 548 string hkdf_input; | 549 string hkdf_input; |
| 549 const size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1; | 550 const size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1; |
| 550 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); | 551 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); |
| 551 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len); | 552 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len); |
| 552 hkdf_input.append(out_params->hkdf_input_suffix); | 553 hkdf_input.append(out_params->hkdf_input_suffix); |
| 553 | 554 |
| 554 if (!CryptoUtils::DeriveKeys( | 555 if (!CryptoUtils::DeriveKeys( |
| 555 out_params->initial_premaster_secret, out_params->aead, | 556 out_params->initial_premaster_secret, out_params->aead, |
| 556 out_params->client_nonce, out_params->server_nonce, hkdf_input, | 557 out_params->client_nonce, out_params->server_nonce, hkdf_input, |
| 557 CryptoUtils::CLIENT, &out_params->initial_crypters)) { | 558 CryptoUtils::CLIENT, &out_params->initial_crypters, |
| 559 NULL /* subkey secret */)) { |
| 558 *error_details = "Symmetric key setup failed"; | 560 *error_details = "Symmetric key setup failed"; |
| 559 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; | 561 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; |
| 560 } | 562 } |
| 561 | 563 |
| 562 return QUIC_NO_ERROR; | 564 return QUIC_NO_ERROR; |
| 563 } | 565 } |
| 564 | 566 |
| 565 QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig( | 567 QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig( |
| 566 const CryptoHandshakeMessage& message, | 568 const CryptoHandshakeMessage& message, |
| 567 QuicWallTime now, | 569 QuicWallTime now, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 | 729 |
| 728 string hkdf_input; | 730 string hkdf_input; |
| 729 const size_t label_len = strlen(QuicCryptoConfig::kForwardSecureLabel) + 1; | 731 const size_t label_len = strlen(QuicCryptoConfig::kForwardSecureLabel) + 1; |
| 730 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); | 732 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); |
| 731 hkdf_input.append(QuicCryptoConfig::kForwardSecureLabel, label_len); | 733 hkdf_input.append(QuicCryptoConfig::kForwardSecureLabel, label_len); |
| 732 hkdf_input.append(out_params->hkdf_input_suffix); | 734 hkdf_input.append(out_params->hkdf_input_suffix); |
| 733 | 735 |
| 734 if (!CryptoUtils::DeriveKeys( | 736 if (!CryptoUtils::DeriveKeys( |
| 735 out_params->forward_secure_premaster_secret, out_params->aead, | 737 out_params->forward_secure_premaster_secret, out_params->aead, |
| 736 out_params->client_nonce, out_params->server_nonce, hkdf_input, | 738 out_params->client_nonce, out_params->server_nonce, hkdf_input, |
| 737 CryptoUtils::CLIENT, &out_params->forward_secure_crypters)) { | 739 CryptoUtils::CLIENT, &out_params->forward_secure_crypters, |
| 740 &out_params->subkey_secret)) { |
| 738 *error_details = "Symmetric key setup failed"; | 741 *error_details = "Symmetric key setup failed"; |
| 739 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; | 742 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; |
| 740 } | 743 } |
| 741 | 744 |
| 742 return QUIC_NO_ERROR; | 745 return QUIC_NO_ERROR; |
| 743 } | 746 } |
| 744 | 747 |
| 745 QuicErrorCode QuicCryptoClientConfig::ProcessServerConfigUpdate( | 748 QuicErrorCode QuicCryptoClientConfig::ProcessServerConfigUpdate( |
| 746 const CryptoHandshakeMessage& server_config_update, | 749 const CryptoHandshakeMessage& server_config_update, |
| 747 QuicWallTime now, | 750 QuicWallTime now, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 return; | 841 return; |
| 839 } | 842 } |
| 840 | 843 |
| 841 // Update canonical version to point at the "most recent" entry. | 844 // Update canonical version to point at the "most recent" entry. |
| 842 canonical_server_map_[suffix_server_id] = server_id; | 845 canonical_server_map_[suffix_server_id] = server_id; |
| 843 | 846 |
| 844 server_state->InitializeFrom(*canonical_state); | 847 server_state->InitializeFrom(*canonical_state); |
| 845 } | 848 } |
| 846 | 849 |
| 847 } // namespace net | 850 } // namespace net |
| OLD | NEW |