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

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

Issue 1811043002: Landing Recent QUIC changes until 2016-03-15 16:26 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add an export clause. 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/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"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 char* output, 86 char* output,
87 size_t* output_length, 87 size_t* output_length,
88 size_t max_output_length) { 88 size_t max_output_length) {
89 if (ciphertext.length() < auth_tag_size_) { 89 if (ciphertext.length() < auth_tag_size_) {
90 return false; 90 return false;
91 } 91 }
92 92
93 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)]; 93 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)];
94 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number); 94 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number);
95 memcpy(nonce, nonce_prefix_, nonce_prefix_size_); 95 memcpy(nonce, nonce_prefix_, nonce_prefix_size_);
96 if (FLAGS_quic_include_path_id_in_iv) { 96 uint64_t path_id_packet_number =
97 uint64_t path_id_packet_number = 97 QuicUtils::PackPathIdAndPacketNumber(path_id, packet_number);
98 QuicUtils::PackPathIdAndPacketNumber(path_id, packet_number); 98 memcpy(nonce + nonce_prefix_size_, &path_id_packet_number,
99 memcpy(nonce + nonce_prefix_size_, &path_id_packet_number, 99 sizeof(path_id_packet_number));
100 sizeof(path_id_packet_number));
101 } else {
102 memcpy(nonce + nonce_prefix_size_, &packet_number, sizeof(packet_number));
103 }
104 if (!EVP_AEAD_CTX_open( 100 if (!EVP_AEAD_CTX_open(
105 ctx_.get(), reinterpret_cast<uint8_t*>(output), output_length, 101 ctx_.get(), reinterpret_cast<uint8_t*>(output), output_length,
106 max_output_length, reinterpret_cast<const uint8_t*>(nonce), 102 max_output_length, reinterpret_cast<const uint8_t*>(nonce),
107 nonce_size, reinterpret_cast<const uint8_t*>(ciphertext.data()), 103 nonce_size, reinterpret_cast<const uint8_t*>(ciphertext.data()),
108 ciphertext.size(), 104 ciphertext.size(),
109 reinterpret_cast<const uint8_t*>(associated_data.data()), 105 reinterpret_cast<const uint8_t*>(associated_data.data()),
110 associated_data.size())) { 106 associated_data.size())) {
111 // Because QuicFramer does trial decryption, decryption errors are expected 107 // Because QuicFramer does trial decryption, decryption errors are expected
112 // when encryption level changes. So we don't log decryption errors. 108 // when encryption level changes. So we don't log decryption errors.
113 ClearOpenSslErrors(); 109 ClearOpenSslErrors();
114 return false; 110 return false;
115 } 111 }
116 return true; 112 return true;
117 } 113 }
118 114
119 StringPiece AeadBaseDecrypter::GetKey() const { 115 StringPiece AeadBaseDecrypter::GetKey() const {
120 return StringPiece(reinterpret_cast<const char*>(key_), key_size_); 116 return StringPiece(reinterpret_cast<const char*>(key_), key_size_);
121 } 117 }
122 118
123 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { 119 StringPiece AeadBaseDecrypter::GetNoncePrefix() const {
124 if (nonce_prefix_size_ == 0) { 120 if (nonce_prefix_size_ == 0) {
125 return StringPiece(); 121 return StringPiece();
126 } 122 }
127 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), 123 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_),
128 nonce_prefix_size_); 124 nonce_prefix_size_);
129 } 125 }
130 126
131 } // namespace net 127 } // 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