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

Side by Side Diff: net/quic/quic_framer.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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 const QuicDecrypter* QuicFramer::alternative_decrypter() const { 1625 const QuicDecrypter* QuicFramer::alternative_decrypter() const {
1626 return alternative_decrypter_.get(); 1626 return alternative_decrypter_.get();
1627 } 1627 }
1628 1628
1629 void QuicFramer::SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter) { 1629 void QuicFramer::SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter) {
1630 DCHECK_GE(level, 0); 1630 DCHECK_GE(level, 0);
1631 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS); 1631 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS);
1632 encrypter_[level].reset(encrypter); 1632 encrypter_[level].reset(encrypter);
1633 } 1633 }
1634 1634
1635 size_t QuicFramer::EncryptInPlace(EncryptionLevel level,
1636 QuicPathId path_id,
1637 QuicPacketNumber packet_number,
1638 size_t ad_len,
1639 size_t total_len,
1640 size_t buffer_len,
1641 char* buffer) {
1642 size_t output_length = 0;
1643 if (!encrypter_[level]->EncryptPacket(
1644 path_id, packet_number,
1645 StringPiece(buffer, ad_len), // Associated data
1646 StringPiece(buffer + ad_len, total_len - ad_len), // Plaintext
1647 buffer + ad_len, // Destination buffer
1648 &output_length, buffer_len - ad_len)) {
1649 RaiseError(QUIC_ENCRYPTION_FAILURE);
1650 return 0;
1651 }
1652
1653 return ad_len + output_length;
1654 }
1655
1635 size_t QuicFramer::EncryptPayload(EncryptionLevel level, 1656 size_t QuicFramer::EncryptPayload(EncryptionLevel level,
1636 QuicPathId path_id, 1657 QuicPathId path_id,
1637 QuicPacketNumber packet_number, 1658 QuicPacketNumber packet_number,
1638 const QuicPacket& packet, 1659 const QuicPacket& packet,
1639 char* buffer, 1660 char* buffer,
1640 size_t buffer_len) { 1661 size_t buffer_len) {
1641 DCHECK(encrypter_[level].get() != nullptr); 1662 DCHECK(encrypter_[level].get() != nullptr);
1642 1663
1643 StringPiece associated_data = packet.AssociatedData(); 1664 StringPiece associated_data = packet.AssociatedData();
1644 // Copy in the header, because the encrypter only populates the encrypted 1665 // Copy in the header, because the encrypter only populates the encrypted
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 2242
2222 bool QuicFramer::RaiseError(QuicErrorCode error) { 2243 bool QuicFramer::RaiseError(QuicErrorCode error) {
2223 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) 2244 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error)
2224 << " detail: " << detailed_error_; 2245 << " detail: " << detailed_error_;
2225 set_error(error); 2246 set_error(error);
2226 visitor_->OnError(this); 2247 visitor_->OnError(this);
2227 return false; 2248 return false;
2228 } 2249 }
2229 2250
2230 } // namespace net 2251 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698