| 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/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (!CryptoUtils::DeriveKeys(out_params->initial_premaster_secret, | 538 if (!CryptoUtils::DeriveKeys(out_params->initial_premaster_secret, |
| 539 out_params->aead, out_params->client_nonce, | 539 out_params->aead, out_params->client_nonce, |
| 540 out_params->server_nonce, hkdf_input, | 540 out_params->server_nonce, hkdf_input, |
| 541 CryptoUtils::CLIENT, &crypters, | 541 CryptoUtils::CLIENT, &crypters, |
| 542 nullptr /* subkey secret */)) { | 542 nullptr /* subkey secret */)) { |
| 543 *error_details = "Symmetric key setup failed"; | 543 *error_details = "Symmetric key setup failed"; |
| 544 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; | 544 return QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED; |
| 545 } | 545 } |
| 546 | 546 |
| 547 const QuicData& cetv_plaintext = cetv.GetSerialized(); | 547 const QuicData& cetv_plaintext = cetv.GetSerialized(); |
| 548 scoped_ptr<QuicData> cetv_ciphertext(crypters.encrypter->EncryptPacket( | 548 const size_t encrypted_len = |
| 549 0 /* sequence number */, | 549 crypters.encrypter->GetCiphertextSize(cetv_plaintext.length()); |
| 550 StringPiece() /* associated data */, | 550 scoped_ptr<char[]> output(new char[encrypted_len]); |
| 551 cetv_plaintext.AsStringPiece())); | 551 size_t output_size = 0; |
| 552 if (!cetv_ciphertext.get()) { | 552 if (!crypters.encrypter->EncryptPacket( |
| 553 0 /* sequence number */, StringPiece() /* associated data */, |
| 554 cetv_plaintext.AsStringPiece(), output.get(), &output_size, |
| 555 encrypted_len)) { |
| 553 *error_details = "Packet encryption failed"; | 556 *error_details = "Packet encryption failed"; |
| 554 return QUIC_ENCRYPTION_FAILURE; | 557 return QUIC_ENCRYPTION_FAILURE; |
| 555 } | 558 } |
| 556 | 559 |
| 557 out->SetStringPiece(kCETV, cetv_ciphertext->AsStringPiece()); | 560 out->SetStringPiece(kCETV, StringPiece(output.get(), output_size)); |
| 558 out->MarkDirty(); | 561 out->MarkDirty(); |
| 559 | 562 |
| 560 out->set_minimum_size(orig_min_size); | 563 out->set_minimum_size(orig_min_size); |
| 561 } | 564 } |
| 562 | 565 |
| 563 // Derive the symmetric keys and set up the encrypters and decrypters. | 566 // Derive the symmetric keys and set up the encrypters and decrypters. |
| 564 // Set the following members of out_params: | 567 // Set the following members of out_params: |
| 565 // out_params->hkdf_input_suffix | 568 // out_params->hkdf_input_suffix |
| 566 // out_params->initial_crypters | 569 // out_params->initial_crypters |
| 567 out_params->hkdf_input_suffix.clear(); | 570 out_params->hkdf_input_suffix.clear(); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 } | 883 } |
| 881 | 884 |
| 882 // Update canonical version to point at the "most recent" entry. | 885 // Update canonical version to point at the "most recent" entry. |
| 883 canonical_server_map_[suffix_server_id] = server_id; | 886 canonical_server_map_[suffix_server_id] = server_id; |
| 884 | 887 |
| 885 server_state->InitializeFrom(*canonical_state); | 888 server_state->InitializeFrom(*canonical_state); |
| 886 return true; | 889 return true; |
| 887 } | 890 } |
| 888 | 891 |
| 889 } // namespace net | 892 } // namespace net |
| OLD | NEW |