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

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

Issue 1660593004: Landing Recent QUIC changes until 01/28/2016 18:41 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0202
Patch Set: Created 4 years, 10 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/crypto/aead_base_decrypter_nss.cc ('k') | net/quic/crypto/aead_base_encrypter_nss.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) 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_decrypter.h" 5 #include "net/quic/crypto/aead_base_decrypter.h"
6 6
7 #include <openssl/err.h> 7 #include <openssl/err.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "net/quic/quic_flags.h" 11 #include "net/quic/quic_flags.h"
12 #include "net/quic/quic_utils.h"
12 13
13 using base::StringPiece; 14 using base::StringPiece;
14 15
15 namespace net { 16 namespace net {
16 17
17 namespace { 18 namespace {
18 19
19 // Clear OpenSSL error stack. 20 // Clear OpenSSL error stack.
20 void ClearOpenSslErrors() { 21 void ClearOpenSslErrors() {
21 while (ERR_get_error()) { 22 while (ERR_get_error()) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 size_t* output_length, 87 size_t* output_length,
87 size_t max_output_length) { 88 size_t max_output_length) {
88 if (ciphertext.length() < auth_tag_size_) { 89 if (ciphertext.length() < auth_tag_size_) {
89 return false; 90 return false;
90 } 91 }
91 92
92 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)]; 93 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)];
93 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number); 94 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number);
94 memcpy(nonce, nonce_prefix_, nonce_prefix_size_); 95 memcpy(nonce, nonce_prefix_, nonce_prefix_size_);
95 if (FLAGS_quic_include_path_id_in_iv) { 96 if (FLAGS_quic_include_path_id_in_iv) {
96 // Setting the nonce below relies on QuicPathId and QuicPacketNumber being
97 // specific sizes.
98 static_assert(sizeof(path_id) == 1, "Size of QuicPathId changed.");
99 static_assert(sizeof(packet_number) == 8,
100 "Size of QuicPacketNumber changed.");
101 // Use path_id and lower 7 bytes of packet_number as lower 8 bytes of nonce.
102 uint64_t path_id_packet_number = 97 uint64_t path_id_packet_number =
103 (static_cast<uint64_t>(path_id) << 56) | packet_number; 98 QuicUtils::PackPathIdAndPacketNumber(path_id, packet_number);
104 DCHECK(path_id != kDefaultPathId || path_id_packet_number == packet_number);
105 memcpy(nonce + nonce_prefix_size_, &path_id_packet_number, 99 memcpy(nonce + nonce_prefix_size_, &path_id_packet_number,
106 sizeof(path_id_packet_number)); 100 sizeof(path_id_packet_number));
107 } else { 101 } else {
108 memcpy(nonce + nonce_prefix_size_, &packet_number, sizeof(packet_number)); 102 memcpy(nonce + nonce_prefix_size_, &packet_number, sizeof(packet_number));
109 } 103 }
110 if (!EVP_AEAD_CTX_open( 104 if (!EVP_AEAD_CTX_open(
111 ctx_.get(), reinterpret_cast<uint8_t*>(output), output_length, 105 ctx_.get(), reinterpret_cast<uint8_t*>(output), output_length,
112 max_output_length, reinterpret_cast<const uint8_t*>(nonce), 106 max_output_length, reinterpret_cast<const uint8_t*>(nonce),
113 nonce_size, reinterpret_cast<const uint8_t*>(ciphertext.data()), 107 nonce_size, reinterpret_cast<const uint8_t*>(ciphertext.data()),
114 ciphertext.size(), 108 ciphertext.size(),
(...skipping 13 matching lines...) Expand all
128 122
129 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { 123 StringPiece AeadBaseDecrypter::GetNoncePrefix() const {
130 if (nonce_prefix_size_ == 0) { 124 if (nonce_prefix_size_ == 0) {
131 return StringPiece(); 125 return StringPiece();
132 } 126 }
133 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), 127 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_),
134 nonce_prefix_size_); 128 nonce_prefix_size_);
135 } 129 }
136 130
137 } // namespace net 131 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/aead_base_decrypter_nss.cc ('k') | net/quic/crypto/aead_base_encrypter_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698