Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: net/quic/crypto/aead_base_encrypter_openssl.cc

Issue 1810743002: Deprecate --quic_include_path_id_in_iv. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116808648
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/aead_base_encrypter.h" 5 #include "net/quic/crypto/aead_base_encrypter.h"
6 6
7 #include <openssl/err.h> 7 #include <openssl/err.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 size_t max_output_length) { 113 size_t max_output_length) {
114 size_t ciphertext_size = GetCiphertextSize(plaintext.length()); 114 size_t ciphertext_size = GetCiphertextSize(plaintext.length());
115 if (max_output_length < ciphertext_size) { 115 if (max_output_length < ciphertext_size) {
116 return false; 116 return false;
117 } 117 }
118 // TODO(ianswett): Introduce a check to ensure that we don't encrypt with the 118 // TODO(ianswett): Introduce a check to ensure that we don't encrypt with the
119 // same packet number twice. 119 // same packet number twice.
120 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number); 120 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number);
121 ALIGNAS(4) char nonce_buffer[kMaxNonceSize]; 121 ALIGNAS(4) char nonce_buffer[kMaxNonceSize];
122 memcpy(nonce_buffer, nonce_prefix_, nonce_prefix_size_); 122 memcpy(nonce_buffer, nonce_prefix_, nonce_prefix_size_);
123 if (FLAGS_quic_include_path_id_in_iv) { 123 uint64_t path_id_packet_number =
124 uint64_t path_id_packet_number = 124 QuicUtils::PackPathIdAndPacketNumber(path_id, packet_number);
125 QuicUtils::PackPathIdAndPacketNumber(path_id, packet_number); 125 memcpy(nonce_buffer + nonce_prefix_size_, &path_id_packet_number,
126 memcpy(nonce_buffer + nonce_prefix_size_, &path_id_packet_number, 126 sizeof(path_id_packet_number));
127 sizeof(path_id_packet_number));
128 } else {
129 memcpy(nonce_buffer + nonce_prefix_size_, &packet_number,
130 sizeof(packet_number));
131 }
132 127
133 if (!Encrypt(StringPiece(nonce_buffer, nonce_size), associated_data, 128 if (!Encrypt(StringPiece(nonce_buffer, nonce_size), associated_data,
134 plaintext, reinterpret_cast<unsigned char*>(output))) { 129 plaintext, reinterpret_cast<unsigned char*>(output))) {
135 return false; 130 return false;
136 } 131 }
137 *output_length = ciphertext_size; 132 *output_length = ciphertext_size;
138 return true; 133 return true;
139 } 134 }
140 135
141 size_t AeadBaseEncrypter::GetKeySize() const { 136 size_t AeadBaseEncrypter::GetKeySize() const {
(...skipping 18 matching lines...) Expand all
160 155
161 StringPiece AeadBaseEncrypter::GetNoncePrefix() const { 156 StringPiece AeadBaseEncrypter::GetNoncePrefix() const {
162 if (nonce_prefix_size_ == 0) { 157 if (nonce_prefix_size_ == 0) {
163 return StringPiece(); 158 return StringPiece();
164 } 159 }
165 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), 160 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_),
166 nonce_prefix_size_); 161 nonce_prefix_size_);
167 } 162 }
168 163
169 } // namespace net 164 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/aead_base_decrypter_openssl.cc ('k') | net/quic/crypto/aes_128_gcm_12_decrypter_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698