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

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

Issue 1810743002: Deprecate --quic_include_path_id_in_iv. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116808648
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/crypto/chacha20_poly1305_decrypter_test.cc ('k') | net/quic/quic_flags.h » ('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 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_rfc7539_decrypter.h" 5 #include "net/quic/crypto/chacha20_poly1305_rfc7539_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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 QuicData* DecryptWithNonce(ChaCha20Poly1305Rfc7539Decrypter* decrypter, 113 QuicData* DecryptWithNonce(ChaCha20Poly1305Rfc7539Decrypter* decrypter,
114 StringPiece nonce, 114 StringPiece nonce,
115 StringPiece associated_data, 115 StringPiece associated_data,
116 StringPiece ciphertext) { 116 StringPiece ciphertext) {
117 QuicPathId path_id = kDefaultPathId; 117 QuicPathId path_id = kDefaultPathId;
118 QuicPacketNumber packet_number; 118 QuicPacketNumber packet_number;
119 StringPiece nonce_prefix(nonce.data(), nonce.size() - sizeof(packet_number)); 119 StringPiece nonce_prefix(nonce.data(), nonce.size() - sizeof(packet_number));
120 decrypter->SetNoncePrefix(nonce_prefix); 120 decrypter->SetNoncePrefix(nonce_prefix);
121 memcpy(&packet_number, nonce.data() + nonce_prefix.size(), 121 memcpy(&packet_number, nonce.data() + nonce_prefix.size(),
122 sizeof(packet_number)); 122 sizeof(packet_number));
123 if (FLAGS_quic_include_path_id_in_iv) { 123 path_id = static_cast<QuicPathId>(
124 path_id = static_cast<QuicPathId>( 124 packet_number >> 8 * (sizeof(packet_number) - sizeof(path_id)));
125 packet_number >> 8 * (sizeof(packet_number) - sizeof(path_id))); 125 packet_number &= UINT64_C(0x00FFFFFFFFFFFFFF);
126 packet_number &= UINT64_C(0x00FFFFFFFFFFFFFF);
127 }
128 scoped_ptr<char[]> output(new char[ciphertext.length()]); 126 scoped_ptr<char[]> output(new char[ciphertext.length()]);
129 size_t output_length = 0; 127 size_t output_length = 0;
130 const bool success = decrypter->DecryptPacket( 128 const bool success = decrypter->DecryptPacket(
131 path_id, packet_number, associated_data, ciphertext, output.get(), 129 path_id, packet_number, associated_data, ciphertext, output.get(),
132 &output_length, ciphertext.length()); 130 &output_length, ciphertext.length());
133 if (!success) { 131 if (!success) {
134 return nullptr; 132 return nullptr;
135 } 133 }
136 return new QuicData(output.release(), output_length, true); 134 return new QuicData(output.release(), output_length, true);
137 } 135 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 174
177 EXPECT_EQ(12u, ct.size() - decrypted->length()); 175 EXPECT_EQ(12u, ct.size() - decrypted->length());
178 ASSERT_EQ(pt.length(), decrypted->length()); 176 ASSERT_EQ(pt.length(), decrypted->length());
179 test::CompareCharArraysWithHexError("plaintext", decrypted->data(), 177 test::CompareCharArraysWithHexError("plaintext", decrypted->data(),
180 pt.length(), pt.data(), pt.length()); 178 pt.length(), pt.data(), pt.length());
181 } 179 }
182 } 180 }
183 181
184 } // namespace test 182 } // namespace test
185 } // namespace net 183 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/chacha20_poly1305_decrypter_test.cc ('k') | net/quic/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698