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

Side by Side Diff: net/quic/crypto/aes_128_gcm_12_decrypter_test.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
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/aes_128_gcm_12_decrypter.h" 5 #include "net/quic/crypto/aes_128_gcm_12_decrypter.h"
6 6
7 #include "net/quic/quic_flags.h" 7 #include "net/quic/quic_flags.h"
8 #include "net/quic/test_tools/quic_test_utils.h" 8 #include "net/quic/test_tools/quic_test_utils.h"
9 9
10 using base::StringPiece; 10 using base::StringPiece;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 QuicData* DecryptWithNonce(Aes128Gcm12Decrypter* decrypter, 199 QuicData* DecryptWithNonce(Aes128Gcm12Decrypter* decrypter,
200 StringPiece nonce, 200 StringPiece nonce,
201 StringPiece associated_data, 201 StringPiece associated_data,
202 StringPiece ciphertext) { 202 StringPiece ciphertext) {
203 QuicPathId path_id = kDefaultPathId; 203 QuicPathId path_id = kDefaultPathId;
204 QuicPacketNumber packet_number; 204 QuicPacketNumber packet_number;
205 StringPiece nonce_prefix(nonce.data(), nonce.size() - sizeof(packet_number)); 205 StringPiece nonce_prefix(nonce.data(), nonce.size() - sizeof(packet_number));
206 decrypter->SetNoncePrefix(nonce_prefix); 206 decrypter->SetNoncePrefix(nonce_prefix);
207 memcpy(&packet_number, nonce.data() + nonce_prefix.size(), 207 memcpy(&packet_number, nonce.data() + nonce_prefix.size(),
208 sizeof(packet_number)); 208 sizeof(packet_number));
209 if (FLAGS_quic_include_path_id_in_iv) { 209 path_id = static_cast<QuicPathId>(
210 path_id = static_cast<QuicPathId>( 210 packet_number >> 8 * (sizeof(packet_number) - sizeof(path_id)));
211 packet_number >> 8 * (sizeof(packet_number) - sizeof(path_id))); 211 packet_number &= UINT64_C(0x00FFFFFFFFFFFFFF);
212 packet_number &= UINT64_C(0x00FFFFFFFFFFFFFF);
213 }
214 scoped_ptr<char[]> output(new char[ciphertext.length()]); 212 scoped_ptr<char[]> output(new char[ciphertext.length()]);
215 size_t output_length = 0; 213 size_t output_length = 0;
216 const bool success = decrypter->DecryptPacket( 214 const bool success = decrypter->DecryptPacket(
217 path_id, packet_number, associated_data, ciphertext, output.get(), 215 path_id, packet_number, associated_data, ciphertext, output.get(),
218 &output_length, ciphertext.length()); 216 &output_length, ciphertext.length());
219 if (!success) { 217 if (!success) {
220 return nullptr; 218 return nullptr;
221 } 219 }
222 return new QuicData(output.release(), output_length, true); 220 return new QuicData(output.release(), output_length, true);
223 } 221 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 280
283 ASSERT_EQ(pt.length(), decrypted->length()); 281 ASSERT_EQ(pt.length(), decrypted->length());
284 test::CompareCharArraysWithHexError("plaintext", decrypted->data(), 282 test::CompareCharArraysWithHexError("plaintext", decrypted->data(),
285 pt.length(), pt.data(), pt.length()); 283 pt.length(), pt.data(), pt.length());
286 } 284 }
287 } 285 }
288 } 286 }
289 287
290 } // namespace test 288 } // namespace test
291 } // namespace net 289 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/aead_base_encrypter_openssl.cc ('k') | net/quic/crypto/chacha20_poly1305_decrypter_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698