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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/crypto_utils.cc ('k') | net/quic/crypto/curve25519_key_exchange.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 (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/crypto_utils.h" 5 #include "net/quic/crypto/crypto_utils.h"
6 6
7 #include "net/quic/test_tools/quic_test_utils.h" 7 #include "net/quic/test_tools/quic_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 "e934f78d7a71dd85420fceeb8cea0317", 61 "e934f78d7a71dd85420fceeb8cea0317",
62 "b8d766b5d3c8aba0009c7ed3de553eba53b4de1030ea91383dcdf724cd8b7217", 62 "b8d766b5d3c8aba0009c7ed3de553eba53b4de1030ea91383dcdf724cd8b7217",
63 32, 63 32,
64 "a9979da0d5f1c1387d7cbe68f5c4163ddb445a03c4ad6ee72cb49d56726d679e" 64 "a9979da0d5f1c1387d7cbe68f5c4163ddb445a03c4ad6ee72cb49d56726d679e"
65 }, 65 },
66 // Don't let the label contain nulls 66 // Don't let the label contain nulls
67 { "14fe51e082ffee7d1b4d8d4ab41f8c55", 67 { "14fe51e082ffee7d1b4d8d4ab41f8c55",
68 "3132333435363700", 68 "3132333435363700",
69 "58585858585858585858585858585858", 69 "58585858585858585858585858585858",
70 16, 70 16,
71 NULL 71 nullptr
72 }, 72 },
73 // Make sure nulls in the context are fine 73 // Make sure nulls in the context are fine
74 { "d862c2e36b0a42f7827c67ebc8d44df7", 74 { "d862c2e36b0a42f7827c67ebc8d44df7",
75 "7a5b95e4e8378123", 75 "7a5b95e4e8378123",
76 "4142434445464700", 76 "4142434445464700",
77 16, 77 16,
78 "12d418c6d0738a2e4d85b2d0170f76e1" 78 "12d418c6d0738a2e4d85b2d0170f76e1"
79 }, 79 },
80 // ... and give a different result than without 80 // ... and give a different result than without
81 { "d862c2e36b0a42f7827c67ebc8d44df7", 81 { "d862c2e36b0a42f7827c67ebc8d44df7",
(...skipping 13 matching lines...) Expand all
95 95
96 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_vector); i++) { 96 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_vector); i++) {
97 // Decode the test vector. 97 // Decode the test vector.
98 string subkey_secret; 98 string subkey_secret;
99 string label; 99 string label;
100 string context; 100 string context;
101 ASSERT_TRUE(DecodeHexString(test_vector[i].subkey_secret, &subkey_secret)); 101 ASSERT_TRUE(DecodeHexString(test_vector[i].subkey_secret, &subkey_secret));
102 ASSERT_TRUE(DecodeHexString(test_vector[i].label, &label)); 102 ASSERT_TRUE(DecodeHexString(test_vector[i].label, &label));
103 ASSERT_TRUE(DecodeHexString(test_vector[i].context, &context)); 103 ASSERT_TRUE(DecodeHexString(test_vector[i].context, &context));
104 size_t result_len = test_vector[i].result_len; 104 size_t result_len = test_vector[i].result_len;
105 bool expect_ok = test_vector[i].expected != NULL; 105 bool expect_ok = test_vector[i].expected != nullptr;
106 string expected; 106 string expected;
107 if (expect_ok) { 107 if (expect_ok) {
108 ASSERT_TRUE(DecodeHexString(test_vector[i].expected, &expected)); 108 ASSERT_TRUE(DecodeHexString(test_vector[i].expected, &expected));
109 } 109 }
110 110
111 string result; 111 string result;
112 bool ok = CryptoUtils::ExportKeyingMaterial(subkey_secret, 112 bool ok = CryptoUtils::ExportKeyingMaterial(subkey_secret,
113 label, 113 label,
114 context, 114 context,
115 result_len, 115 result_len,
116 &result); 116 &result);
117 EXPECT_EQ(expect_ok, ok); 117 EXPECT_EQ(expect_ok, ok);
118 if (expect_ok) { 118 if (expect_ok) {
119 EXPECT_EQ(result_len, result.length()); 119 EXPECT_EQ(result_len, result.length());
120 test::CompareCharArraysWithHexError("HKDF output", 120 test::CompareCharArraysWithHexError("HKDF output",
121 result.data(), 121 result.data(),
122 result.length(), 122 result.length(),
123 expected.data(), 123 expected.data(),
124 expected.length()); 124 expected.length());
125 } 125 }
126 } 126 }
127 } 127 }
128 128
129 } // namespace 129 } // namespace
130 } // namespace test 130 } // namespace test
131 } // namespace net 131 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/crypto_utils.cc ('k') | net/quic/crypto/curve25519_key_exchange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698