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

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

Issue 2681793002: Landing Recent QUIC changes until 5:30 PM, Feb 3, 2017 UTC-5 (Closed)
Patch Set: sync and rebase 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/failing_proof_source.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) 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 15 matching lines...) Expand all
141 sizeof(orbit.size())), 141 sizeof(orbit.size())),
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 CryptoHandshakeMessage inchoate_chlo = crypto_test_utils::CreateCHLO(
152 CryptoHandshakeMessage inchoate_chlo = CryptoTestUtils::Message( 152 {{"PDMD", "X509"},
153 "CHLO", 153 {"AEAD", "AESG"},
154 "PDMD", "X509", 154 {"KEXS", "C255"},
155 "AEAD", "AESG", 155 {"COPT", "SREJ"},
156 "KEXS", "C255", 156 {"PUBS", pub_hex},
157 "COPT", "SREJ", 157 {"NONC", nonce_hex},
158 "PUBS", pub_hex.c_str(), 158 {"VER\0", QuicTagToString(QuicVersionToQuicTag(version))}},
159 "NONC", nonce_hex.c_str(), 159 kClientHelloMinimumSize);
160 "VER\0", QuicTagToString(QuicVersionToQuicTag(version)).c_str(),
161 "$padding", static_cast<int>(kClientHelloMinimumSize),
162 nullptr);
163 // clang-format on
164 160
165 CryptoTestUtils::GenerateFullCHLO(inchoate_chlo, &crypto_config, server_addr, 161 crypto_test_utils::GenerateFullCHLO(
166 client_addr, version, &clock, signed_config, 162 inchoate_chlo, &crypto_config, server_addr, client_addr, version, &clock,
167 &compressed_certs_cache, &full_chlo); 163 signed_config, &compressed_certs_cache, &full_chlo);
168 // Verify that full_chlo can pass crypto_config's verification. 164 // Verify that full_chlo can pass crypto_config's verification.
169 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock, 165 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock,
170 signed_config, &compressed_certs_cache); 166 signed_config, &compressed_certs_cache);
171 crypto_config.ValidateClientHello( 167 crypto_config.ValidateClientHello(
172 full_chlo, client_addr.host(), server_addr, version, &clock, 168 full_chlo, client_addr.host(), server_addr, version, &clock,
173 signed_config, shlo_verifier.GetValidateClientHelloCallback()); 169 signed_config, shlo_verifier.GetValidateClientHelloCallback());
174 } 170 }
175 171
176 } // namespace test 172 } // namespace test
177 } // namespace net 173 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.cc ('k') | net/quic/test_tools/failing_proof_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698