OLD | NEW |
---|---|
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 28 matching lines...) Expand all Loading... | |
39 { "www.google.com........", "www.google.com", }, | 39 { "www.google.com........", "www.google.com", }, |
40 }; | 40 }; |
41 | 41 |
42 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 42 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
43 EXPECT_EQ(std::string(tests[i].expected), | 43 EXPECT_EQ(std::string(tests[i].expected), |
44 CryptoUtils::NormalizeHostname(tests[i].input)); | 44 CryptoUtils::NormalizeHostname(tests[i].input)); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 TEST(CryptoUtilsTest, TestExportKeyingMaterial) { | 48 TEST(CryptoUtilsTest, TestExportKeyingMaterial) { |
49 const struct TestVector { | 49 const struct TestVector { |
wtc
2014/08/11 20:59:16
This struct is named "TestVector". Why does a comp
| |
50 // Input (strings of hexadecimal digits): | 50 // Input (strings of hexadecimal digits): |
51 const char* subkey_secret; | 51 const char* subkey_secret; |
52 const char* label; | 52 const char* label; |
53 const char* context; | 53 const char* context; |
54 size_t result_len; | 54 size_t result_len; |
55 | 55 |
56 // Expected output (string of hexadecimal digits): | 56 // Expected output (string of hexadecimal digits): |
57 const char* expected; // Null if it should fail. | 57 const char* expected; // Null if it should fail. |
58 } test_vector[] = { | 58 } test_vector[] = { |
59 // Try a typical input | 59 // Try a typical input |
(...skipping 26 matching lines...) Expand all Loading... | |
86 }, | 86 }, |
87 // Try weird lengths | 87 // Try weird lengths |
88 { "d0ec8a34f6cc9a8c96", | 88 { "d0ec8a34f6cc9a8c96", |
89 "49711798cc6251", | 89 "49711798cc6251", |
90 "933d4a2f30d22f089cfba842791116adc121e0", | 90 "933d4a2f30d22f089cfba842791116adc121e0", |
91 23, | 91 23, |
92 "c9a46ed0757bd1812f1f21b4d41e62125fec8364a21db7" | 92 "c9a46ed0757bd1812f1f21b4d41e62125fec8364a21db7" |
93 }, | 93 }, |
94 }; | 94 }; |
95 | 95 |
96 for (size_t i = 0; i < arraysize(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 != NULL; |
106 string expected; | 106 string expected; |
(...skipping 15 matching lines...) Expand all Loading... | |
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 |
OLD | NEW |