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

Side by Side Diff: net/quic/test_tools/crypto_test_utils_test.cc

Issue 2671333004: Convert class-full-of-statics CryptoTestUtils into a namespace (Closed)
Patch Set: Created 3 years, 10 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/test_tools/crypto_test_utils.cc ('k') | net/quic/test_tools/fake_proof_source.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test_tools/crypto_test_utils.h" 5 #include "net/quic/test_tools/crypto_test_utils.h"
6 6
7 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" 7 #include "net/quic/core/crypto/crypto_server_config_protobuf.h"
8 #include "net/quic/core/quic_utils.h" 8 #include "net/quic/core/quic_utils.h"
9 #include "net/quic/platform/api/quic_text_utils.h" 9 #include "net/quic/platform/api/quic_text_utils.h"
10 #include "net/quic/test_tools/mock_clock.h" 10 #include "net/quic/test_tools/mock_clock.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_; 106 QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_;
107 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> 107 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result>
108 result_; 108 result_;
109 }; 109 };
110 110
111 TEST(CryptoTestUtilsTest, TestGenerateFullCHLO) { 111 TEST(CryptoTestUtilsTest, TestGenerateFullCHLO) {
112 MockClock clock; 112 MockClock clock;
113 QuicCryptoServerConfig crypto_config( 113 QuicCryptoServerConfig crypto_config(
114 QuicCryptoServerConfig::TESTING, QuicRandom::GetInstance(), 114 QuicCryptoServerConfig::TESTING, QuicRandom::GetInstance(),
115 CryptoTestUtils::ProofSourceForTesting()); 115 crypto_test_utils::ProofSourceForTesting());
116 QuicSocketAddress server_addr; 116 QuicSocketAddress server_addr;
117 QuicSocketAddress client_addr(QuicIpAddress::Loopback4(), 1); 117 QuicSocketAddress client_addr(QuicIpAddress::Loopback4(), 1);
118 QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config( 118 QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config(
119 new QuicSignedServerConfig); 119 new QuicSignedServerConfig);
120 QuicCompressedCertsCache compressed_certs_cache( 120 QuicCompressedCertsCache compressed_certs_cache(
121 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize); 121 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize);
122 CryptoHandshakeMessage full_chlo; 122 CryptoHandshakeMessage full_chlo;
123 123
124 QuicCryptoServerConfig::ConfigOptions old_config_options; 124 QuicCryptoServerConfig::ConfigOptions old_config_options;
125 old_config_options.id = "old-config-id"; 125 old_config_options.id = "old-config-id";
(...skipping 16 matching lines...) Expand all
142 &nonce); 142 &nonce);
143 string nonce_hex = "#" + QuicTextUtils::HexEncode(nonce); 143 string nonce_hex = "#" + QuicTextUtils::HexEncode(nonce);
144 144
145 char public_value[32]; 145 char public_value[32];
146 memset(public_value, 42, sizeof(public_value)); 146 memset(public_value, 42, sizeof(public_value));
147 string pub_hex = 147 string pub_hex =
148 "#" + QuicTextUtils::HexEncode(public_value, sizeof(public_value)); 148 "#" + QuicTextUtils::HexEncode(public_value, sizeof(public_value));
149 149
150 QuicVersion version(AllSupportedVersions().front()); 150 QuicVersion version(AllSupportedVersions().front());
151 // clang-format off 151 // clang-format off
152 CryptoHandshakeMessage inchoate_chlo = CryptoTestUtils::Message( 152 CryptoHandshakeMessage inchoate_chlo = crypto_test_utils::Message(
153 "CHLO", 153 "CHLO",
154 "PDMD", "X509", 154 "PDMD", "X509",
155 "AEAD", "AESG", 155 "AEAD", "AESG",
156 "KEXS", "C255", 156 "KEXS", "C255",
157 "COPT", "SREJ", 157 "COPT", "SREJ",
158 "PUBS", pub_hex.c_str(), 158 "PUBS", pub_hex.c_str(),
159 "NONC", nonce_hex.c_str(), 159 "NONC", nonce_hex.c_str(),
160 "VER\0", QuicTagToString(QuicVersionToQuicTag(version)).c_str(), 160 "VER\0", QuicTagToString(QuicVersionToQuicTag(version)).c_str(),
161 "$padding", static_cast<int>(kClientHelloMinimumSize), 161 "$padding", static_cast<int>(kClientHelloMinimumSize),
162 nullptr); 162 nullptr);
163 // clang-format on 163 // clang-format on
164 164
165 CryptoTestUtils::GenerateFullCHLO(inchoate_chlo, &crypto_config, server_addr, 165 crypto_test_utils::GenerateFullCHLO(
166 client_addr, version, &clock, signed_config, 166 inchoate_chlo, &crypto_config, server_addr, client_addr, version, &clock,
167 &compressed_certs_cache, &full_chlo); 167 signed_config, &compressed_certs_cache, &full_chlo);
168 // Verify that full_chlo can pass crypto_config's verification. 168 // Verify that full_chlo can pass crypto_config's verification.
169 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock, 169 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock,
170 signed_config, &compressed_certs_cache); 170 signed_config, &compressed_certs_cache);
171 crypto_config.ValidateClientHello( 171 crypto_config.ValidateClientHello(
172 full_chlo, client_addr.host(), server_addr, version, &clock, 172 full_chlo, client_addr.host(), server_addr, version, &clock,
173 signed_config, shlo_verifier.GetValidateClientHelloCallback()); 173 signed_config, shlo_verifier.GetValidateClientHelloCallback());
174 } 174 }
175 175
176 } // namespace test 176 } // namespace test
177 } // namespace net 177 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.cc ('k') | net/quic/test_tools/fake_proof_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698