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

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

Issue 2603723002: Add a new QUIC platform API for text utilities. (Closed)
Patch Set: net/tools/quic/quic_packet_printer_bin.cc Created 3 years, 11 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 (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/core/crypto/crypto_utils.h" 5 #include "net/quic/core/crypto/crypto_utils.h"
6 6
7 #include "net/quic/core/quic_utils.h" 7 #include "net/quic/core/quic_utils.h"
8 #include "net/quic/platform/api/quic_text_utils.h"
8 #include "net/quic/test_tools/quic_test_utils.h" 9 #include "net/quic/test_tools/quic_test_utils.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 using std::string; 12 using std::string;
12 13
13 namespace net { 14 namespace net {
14 namespace test { 15 namespace test {
15 namespace { 16 namespace {
16 17
17 TEST(CryptoUtilsTest, IsValidSNI) { 18 TEST(CryptoUtilsTest, IsValidSNI) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 {"d862c2e36b0a42f7827c67ebc8d44df7", "7a5b95e4e8378123", "41424344454647", 87 {"d862c2e36b0a42f7827c67ebc8d44df7", "7a5b95e4e8378123", "41424344454647",
87 16, "abfa1c479a6e3ffb98a11dee7d196408"}, 88 16, "abfa1c479a6e3ffb98a11dee7d196408"},
88 // Try weird lengths 89 // Try weird lengths
89 {"d0ec8a34f6cc9a8c96", "49711798cc6251", 90 {"d0ec8a34f6cc9a8c96", "49711798cc6251",
90 "933d4a2f30d22f089cfba842791116adc121e0", 23, 91 "933d4a2f30d22f089cfba842791116adc121e0", 23,
91 "c9a46ed0757bd1812f1f21b4d41e62125fec8364a21db7"}, 92 "c9a46ed0757bd1812f1f21b4d41e62125fec8364a21db7"},
92 }; 93 };
93 94
94 for (size_t i = 0; i < arraysize(test_vector); i++) { 95 for (size_t i = 0; i < arraysize(test_vector); i++) {
95 // Decode the test vector. 96 // Decode the test vector.
96 string subkey_secret = QuicUtils::HexDecode(test_vector[i].subkey_secret); 97 string subkey_secret =
97 string label = QuicUtils::HexDecode(test_vector[i].label); 98 QuicTextUtils::HexDecode(test_vector[i].subkey_secret);
98 string context = QuicUtils::HexDecode(test_vector[i].context); 99 string label = QuicTextUtils::HexDecode(test_vector[i].label);
100 string context = QuicTextUtils::HexDecode(test_vector[i].context);
99 size_t result_len = test_vector[i].result_len; 101 size_t result_len = test_vector[i].result_len;
100 bool expect_ok = test_vector[i].expected != nullptr; 102 bool expect_ok = test_vector[i].expected != nullptr;
101 string expected; 103 string expected;
102 if (expect_ok) { 104 if (expect_ok) {
103 expected = QuicUtils::HexDecode(test_vector[i].expected); 105 expected = QuicTextUtils::HexDecode(test_vector[i].expected);
104 } 106 }
105 107
106 string result; 108 string result;
107 bool ok = CryptoUtils::ExportKeyingMaterial(subkey_secret, label, context, 109 bool ok = CryptoUtils::ExportKeyingMaterial(subkey_secret, label, context,
108 result_len, &result); 110 result_len, &result);
109 EXPECT_EQ(expect_ok, ok); 111 EXPECT_EQ(expect_ok, ok);
110 if (expect_ok) { 112 if (expect_ok) {
111 EXPECT_EQ(result_len, result.length()); 113 EXPECT_EQ(result_len, result.length());
112 test::CompareCharArraysWithHexError("HKDF output", result.data(), 114 test::CompareCharArraysWithHexError("HKDF output", result.data(),
113 result.length(), expected.data(), 115 result.length(), expected.data(),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 CryptoUtils::HandshakeFailureReasonToString(MAX_FAILURE_REASON)); 188 CryptoUtils::HandshakeFailureReasonToString(MAX_FAILURE_REASON));
187 EXPECT_STREQ( 189 EXPECT_STREQ(
188 "INVALID_HANDSHAKE_FAILURE_REASON", 190 "INVALID_HANDSHAKE_FAILURE_REASON",
189 CryptoUtils::HandshakeFailureReasonToString( 191 CryptoUtils::HandshakeFailureReasonToString(
190 static_cast<HandshakeFailureReason>(MAX_FAILURE_REASON + 1))); 192 static_cast<HandshakeFailureReason>(MAX_FAILURE_REASON + 1)));
191 } 193 }
192 194
193 } // namespace 195 } // namespace
194 } // namespace test 196 } // namespace test
195 } // namespace net 197 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/crypto_server_test.cc ('k') | net/quic/core/crypto/quic_compressed_certs_cache_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698