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

Side by Side Diff: net/quic/crypto/chacha20_poly1305_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chacha20_poly1305_decrypter.h" 5 #include "net/quic/crypto/chacha20_poly1305_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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 QuicData* DecryptWithNonce(ChaCha20Poly1305Decrypter* decrypter, 75 QuicData* DecryptWithNonce(ChaCha20Poly1305Decrypter* decrypter,
76 StringPiece nonce, 76 StringPiece nonce,
77 StringPiece associated_data, 77 StringPiece associated_data,
78 StringPiece ciphertext) { 78 StringPiece ciphertext) {
79 QuicPathId path_id = kDefaultPathId; 79 QuicPathId path_id = kDefaultPathId;
80 QuicPacketNumber packet_number; 80 QuicPacketNumber packet_number;
81 StringPiece nonce_prefix(nonce.data(), nonce.size() - sizeof(packet_number)); 81 StringPiece nonce_prefix(nonce.data(), nonce.size() - sizeof(packet_number));
82 decrypter->SetNoncePrefix(nonce_prefix); 82 decrypter->SetNoncePrefix(nonce_prefix);
83 memcpy(&packet_number, nonce.data() + nonce_prefix.size(), 83 memcpy(&packet_number, nonce.data() + nonce_prefix.size(),
84 sizeof(packet_number)); 84 sizeof(packet_number));
85 if (FLAGS_quic_include_path_id_in_iv) { 85 path_id = static_cast<QuicPathId>(
86 path_id = static_cast<QuicPathId>( 86 packet_number >> 8 * (sizeof(packet_number) - sizeof(path_id)));
87 packet_number >> 8 * (sizeof(packet_number) - sizeof(path_id))); 87 packet_number &= UINT64_C(0x00FFFFFFFFFFFFFF);
88 packet_number &= UINT64_C(0x00FFFFFFFFFFFFFF);
89 }
90 scoped_ptr<char[]> output(new char[ciphertext.length()]); 88 scoped_ptr<char[]> output(new char[ciphertext.length()]);
91 size_t output_length = 0; 89 size_t output_length = 0;
92 const bool success = decrypter->DecryptPacket( 90 const bool success = decrypter->DecryptPacket(
93 path_id, packet_number, associated_data, ciphertext, output.get(), 91 path_id, packet_number, associated_data, ciphertext, output.get(),
94 &output_length, ciphertext.length()); 92 &output_length, ciphertext.length());
95 if (!success) { 93 if (!success) {
96 return nullptr; 94 return nullptr;
97 } 95 }
98 return new QuicData(output.release(), output_length, true); 96 return new QuicData(output.release(), output_length, true);
99 } 97 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 EXPECT_TRUE(has_pt); 129 EXPECT_TRUE(has_pt);
132 130
133 ASSERT_EQ(pt.length(), decrypted->length()); 131 ASSERT_EQ(pt.length(), decrypted->length());
134 test::CompareCharArraysWithHexError("plaintext", decrypted->data(), 132 test::CompareCharArraysWithHexError("plaintext", decrypted->data(),
135 pt.length(), pt.data(), pt.length()); 133 pt.length(), pt.data(), pt.length());
136 } 134 }
137 } 135 }
138 136
139 } // namespace test 137 } // namespace test
140 } // namespace net 138 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/aes_128_gcm_12_decrypter_test.cc ('k') | net/quic/crypto/chacha20_poly1305_rfc7539_decrypter_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698