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

Unified Diff: net/quic/quic_packet_creator.cc

Issue 1785513003: Simplify QUIC's encryption path now that FEC is gone. Protected by FLAG_quic_inplace_encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116261116
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_creator.cc
diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc
index dd40b2f5856e85596f0f1f8d24948818ce3d38c7..1cd9e3af30b73b9e39f944192f9582941a094f45 100644
--- a/net/quic/quic_packet_creator.cc
+++ b/net/quic/quic_packet_creator.cc
@@ -422,13 +422,6 @@ void QuicPacketCreator::SerializePacket(char* encrypted_buffer,
MaybeAddPadding();
DCHECK_GE(max_plaintext_size_, packet_size_);
- // ACK Frames will be truncated due to length only if they're the only frame
- // in the packet, and if packet_size_ was set to max_plaintext_size_. If
- // truncation due to length occurred, then GetSerializedFrameLength will have
- // returned all bytes free.
- bool possibly_truncated_by_length = packet_size_ == max_plaintext_size_ &&
- queued_frames_.size() == 1 &&
- queued_frames_.back().type == ACK_FRAME;
// Use the packet_size_ instead of the buffer size to ensure smaller
// packet sizes are properly used.
size_t length = framer_->BuildDataPacket(header, queued_frames_,
@@ -438,24 +431,36 @@ void QuicPacketCreator::SerializePacket(char* encrypted_buffer,
return;
}
- // TODO(ianswett) Consider replacing QuicPacket with something else, since
- // it's only used to provide convenience methods to FEC and encryption.
- QuicPacket packet(
- encrypted_buffer, length,
- /* owns_buffer */ false, header.public_header.connection_id_length,
- header.public_header.version_flag, header.public_header.multipath_flag,
- header.public_header.packet_number_length);
-
+ // ACK Frames will be truncated due to length only if they're the only frame
+ // in the packet, and if packet_size_ was set to max_plaintext_size_. If
+ // truncation due to length occurred, then GetSerializedFrameLength will have
+ // returned all bytes free.
+ bool possibly_truncated_by_length = packet_size_ == max_plaintext_size_ &&
+ queued_frames_.size() == 1 &&
+ queued_frames_.back().type == ACK_FRAME;
// Because of possible truncation, we can't be confident that our
// packet size calculation worked correctly.
if (!possibly_truncated_by_length) {
DCHECK_EQ(packet_size_, length);
}
- // Immediately encrypt the packet, to ensure we don't encrypt the same
- // packet number multiple times.
- size_t encrypted_length = framer_->EncryptPayload(
- packet_.encryption_level, packet_.path_id, packet_.packet_number, packet,
- encrypted_buffer, encrypted_buffer_len);
+ size_t encrypted_length = 0;
+ if (FLAGS_quic_inplace_encryption2) {
+ const size_t ad_len = GetStartOfEncryptedData(header);
+ encrypted_length = framer_->EncryptInPlace(
+ packet_.encryption_level, packet_.path_id, packet_.packet_number,
+ ad_len, length, encrypted_buffer_len, encrypted_buffer);
+ } else {
+ QuicPacket packet(
+ encrypted_buffer, length,
+ /* owns_buffer */ false, header.public_header.connection_id_length,
+ header.public_header.version_flag, header.public_header.multipath_flag,
+ header.public_header.packet_number_length);
+ // Immediately encrypt the packet, to ensure we don't encrypt the same
+ // packet number multiple times.
+ encrypted_length = framer_->EncryptPayload(
+ packet_.encryption_level, packet_.path_id, packet_.packet_number,
+ packet, encrypted_buffer, encrypted_buffer_len);
+ }
if (encrypted_length == 0) {
QUIC_BUG << "Failed to encrypt packet number " << packet_.packet_number;
return;
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698