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

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

Issue 763833003: Remove using namespace in net/quic/quic_stream_sequencer.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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_encrypter.h" 5 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
6 6
7 #include <string>
8
7 #include "net/quic/test_tools/quic_test_utils.h" 9 #include "net/quic/test_tools/quic_test_utils.h"
8 10
9 using base::StringPiece; 11 using base::StringPiece;
10 12
11 namespace { 13 namespace {
12 14
13 // The AES GCM test vectors come from the file gcmEncryptExtIV128.rsp 15 // The AES GCM test vectors come from the file gcmEncryptExtIV128.rsp
14 // downloaded from http://csrc.nist.gov/groups/STM/cavp/index.html on 16 // downloaded from http://csrc.nist.gov/groups/STM/cavp/index.html on
15 // 2013-02-01. The test vectors in that file look like this: 17 // 2013-02-01. The test vectors in that file look like this:
16 // 18 //
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return new QuicData(ciphertext.release(), ciphertext_size, true); 225 return new QuicData(ciphertext.release(), ciphertext_size, true);
224 } 226 }
225 227
226 TEST(Aes128Gcm12EncrypterTest, Encrypt) { 228 TEST(Aes128Gcm12EncrypterTest, Encrypt) {
227 for (size_t i = 0; i < arraysize(test_group_array); i++) { 229 for (size_t i = 0; i < arraysize(test_group_array); i++) {
228 SCOPED_TRACE(i); 230 SCOPED_TRACE(i);
229 const TestVector* test_vectors = test_group_array[i]; 231 const TestVector* test_vectors = test_group_array[i];
230 const TestGroupInfo& test_info = test_group_info[i]; 232 const TestGroupInfo& test_info = test_group_info[i];
231 for (size_t j = 0; test_vectors[j].key != nullptr; j++) { 233 for (size_t j = 0; test_vectors[j].key != nullptr; j++) {
232 // Decode the test vector. 234 // Decode the test vector.
233 string key; 235 std::string key;
234 string iv; 236 std::string iv;
235 string pt; 237 std::string pt;
236 string aad; 238 std::string aad;
237 string ct; 239 std::string ct;
238 string tag; 240 std::string tag;
239 ASSERT_TRUE(DecodeHexString(test_vectors[j].key, &key)); 241 ASSERT_TRUE(DecodeHexString(test_vectors[j].key, &key));
240 ASSERT_TRUE(DecodeHexString(test_vectors[j].iv, &iv)); 242 ASSERT_TRUE(DecodeHexString(test_vectors[j].iv, &iv));
241 ASSERT_TRUE(DecodeHexString(test_vectors[j].pt, &pt)); 243 ASSERT_TRUE(DecodeHexString(test_vectors[j].pt, &pt));
242 ASSERT_TRUE(DecodeHexString(test_vectors[j].aad, &aad)); 244 ASSERT_TRUE(DecodeHexString(test_vectors[j].aad, &aad));
243 ASSERT_TRUE(DecodeHexString(test_vectors[j].ct, &ct)); 245 ASSERT_TRUE(DecodeHexString(test_vectors[j].ct, &ct));
244 ASSERT_TRUE(DecodeHexString(test_vectors[j].tag, &tag)); 246 ASSERT_TRUE(DecodeHexString(test_vectors[j].tag, &tag));
245 247
246 // The test vector's lengths should look sane. Note that the lengths 248 // The test vector's lengths should look sane. Note that the lengths
247 // in |test_info| are in bits. 249 // in |test_info| are in bits.
248 EXPECT_EQ(test_info.key_len, key.length() * 8); 250 EXPECT_EQ(test_info.key_len, key.length() * 8);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 289
288 TEST(Aes128Gcm12EncrypterTest, GetCiphertextSize) { 290 TEST(Aes128Gcm12EncrypterTest, GetCiphertextSize) {
289 Aes128Gcm12Encrypter encrypter; 291 Aes128Gcm12Encrypter encrypter;
290 EXPECT_EQ(1012u, encrypter.GetCiphertextSize(1000)); 292 EXPECT_EQ(1012u, encrypter.GetCiphertextSize(1000));
291 EXPECT_EQ(112u, encrypter.GetCiphertextSize(100)); 293 EXPECT_EQ(112u, encrypter.GetCiphertextSize(100));
292 EXPECT_EQ(22u, encrypter.GetCiphertextSize(10)); 294 EXPECT_EQ(22u, encrypter.GetCiphertextSize(10));
293 } 295 }
294 296
295 } // namespace test 297 } // namespace test
296 } // namespace net 298 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698