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

Side by Side Diff: net/quic/quic_crypto_server_stream.cc

Issue 763833003: Remove using namespace in net/quic/quic_stream_sequencer.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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) 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/quic_crypto_server_stream.h" 5 #include "net/quic/quic_crypto_server_stream.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "crypto/secure_hash.h" 8 #include "crypto/secure_hash.h"
9 #include "net/quic/crypto/cached_network_parameters.h" 9 #include "net/quic/crypto/cached_network_parameters.h"
10 #include "net/quic/crypto/crypto_protocol.h" 10 #include "net/quic/crypto/crypto_protocol.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 validate_client_hello_cb_); 78 validate_client_hello_cb_);
79 } 79 }
80 80
81 void QuicCryptoServerStream::FinishProcessingHandshakeMessage( 81 void QuicCryptoServerStream::FinishProcessingHandshakeMessage(
82 const CryptoHandshakeMessage& message, 82 const CryptoHandshakeMessage& message,
83 const ValidateClientHelloResultCallback::Result& result) { 83 const ValidateClientHelloResultCallback::Result& result) {
84 // Clear the callback that got us here. 84 // Clear the callback that got us here.
85 DCHECK(validate_client_hello_cb_ != nullptr); 85 DCHECK(validate_client_hello_cb_ != nullptr);
86 validate_client_hello_cb_ = nullptr; 86 validate_client_hello_cb_ = nullptr;
87 87
88 string error_details; 88 std::string error_details;
89 CryptoHandshakeMessage reply; 89 CryptoHandshakeMessage reply;
90 QuicErrorCode error = ProcessClientHello( 90 QuicErrorCode error = ProcessClientHello(
91 message, result, &reply, &error_details); 91 message, result, &reply, &error_details);
92 92
93 if (error != QUIC_NO_ERROR) { 93 if (error != QUIC_NO_ERROR) {
94 CloseConnectionWithDetails(error, error_details); 94 CloseConnectionWithDetails(error, error_details);
95 return; 95 return;
96 } 96 }
97 97
98 if (reply.tag() != kSHLO) { 98 if (reply.tag() != kSHLO) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 crypto_negotiated_params_, 168 crypto_negotiated_params_,
169 cached_network_params, 169 cached_network_params,
170 &server_config_update_message)) { 170 &server_config_update_message)) {
171 DVLOG(1) << "Server: Failed to build server config update (SCUP)!"; 171 DVLOG(1) << "Server: Failed to build server config update (SCUP)!";
172 return; 172 return;
173 } 173 }
174 174
175 DVLOG(1) << "Server: Sending server config update: " 175 DVLOG(1) << "Server: Sending server config update: "
176 << server_config_update_message.DebugString(); 176 << server_config_update_message.DebugString();
177 const QuicData& data = server_config_update_message.GetSerialized(); 177 const QuicData& data = server_config_update_message.GetSerialized();
178 WriteOrBufferData(string(data.data(), data.length()), false, nullptr); 178 WriteOrBufferData(std::string(data.data(), data.length()), false, nullptr);
179 179
180 ++num_server_config_update_messages_sent_; 180 ++num_server_config_update_messages_sent_;
181 } 181 }
182 182
183 void QuicCryptoServerStream::OnServerHelloAcked() { 183 void QuicCryptoServerStream::OnServerHelloAcked() {
184 session()->connection()->OnHandshakeComplete(); 184 session()->connection()->OnHandshakeComplete();
185 } 185 }
186 186
187 void QuicCryptoServerStream::set_previous_cached_network_params( 187 void QuicCryptoServerStream::set_previous_cached_network_params(
188 CachedNetworkParameters cached_network_params) { 188 CachedNetworkParameters cached_network_params) {
189 previous_cached_network_params_.reset( 189 previous_cached_network_params_.reset(
190 new CachedNetworkParameters(cached_network_params)); 190 new CachedNetworkParameters(cached_network_params));
191 } 191 }
192 192
193 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID( 193 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID(
194 string* output) const { 194 std::string* output) const {
195 if (!encryption_established_ || 195 if (!encryption_established_ ||
196 crypto_negotiated_params_.channel_id.empty()) { 196 crypto_negotiated_params_.channel_id.empty()) {
197 return false; 197 return false;
198 } 198 }
199 199
200 const string& channel_id(crypto_negotiated_params_.channel_id); 200 const std::string& channel_id(crypto_negotiated_params_.channel_id);
201 scoped_ptr<crypto::SecureHash> hash( 201 scoped_ptr<crypto::SecureHash> hash(
202 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 202 crypto::SecureHash::Create(crypto::SecureHash::SHA256));
203 hash->Update(channel_id.data(), channel_id.size()); 203 hash->Update(channel_id.data(), channel_id.size());
204 uint8 digest[32]; 204 uint8 digest[32];
205 hash->Finish(digest, sizeof(digest)); 205 hash->Finish(digest, sizeof(digest));
206 206
207 base::Base64Encode(string( 207 base::Base64Encode(std::string(
208 reinterpret_cast<const char*>(digest), sizeof(digest)), output); 208 reinterpret_cast<const char*>(digest), sizeof(digest)), output);
209 // Remove padding. 209 // Remove padding.
210 size_t len = output->size(); 210 size_t len = output->size();
211 if (len >= 2) { 211 if (len >= 2) {
212 if ((*output)[len - 1] == '=') { 212 if ((*output)[len - 1] == '=') {
213 len--; 213 len--;
214 if ((*output)[len - 1] == '=') { 214 if ((*output)[len - 1] == '=') {
215 len--; 215 len--;
216 } 216 }
217 output->resize(len); 217 output->resize(len);
218 } 218 }
219 } 219 }
220 return true; 220 return true;
221 } 221 }
222 222
223 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( 223 QuicErrorCode QuicCryptoServerStream::ProcessClientHello(
224 const CryptoHandshakeMessage& message, 224 const CryptoHandshakeMessage& message,
225 const ValidateClientHelloResultCallback::Result& result, 225 const ValidateClientHelloResultCallback::Result& result,
226 CryptoHandshakeMessage* reply, 226 CryptoHandshakeMessage* reply,
227 string* error_details) { 227 std::string* error_details) {
228 // Store the bandwidth estimate from the client. 228 // Store the bandwidth estimate from the client.
229 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { 229 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) {
230 previous_cached_network_params_.reset( 230 previous_cached_network_params_.reset(
231 new CachedNetworkParameters(result.cached_network_params)); 231 new CachedNetworkParameters(result.cached_network_params));
232 } 232 }
233 233
234 return crypto_config_.ProcessClientHello( 234 return crypto_config_.ProcessClientHello(
235 result, 235 result,
236 session()->connection()->connection_id(), 236 session()->connection()->connection_id(),
237 session()->connection()->peer_address(), 237 session()->connection()->peer_address(),
(...skipping 20 matching lines...) Expand all
258 258
259 void QuicCryptoServerStream::ValidateCallback::RunImpl( 259 void QuicCryptoServerStream::ValidateCallback::RunImpl(
260 const CryptoHandshakeMessage& client_hello, 260 const CryptoHandshakeMessage& client_hello,
261 const Result& result) { 261 const Result& result) {
262 if (parent_ != nullptr) { 262 if (parent_ != nullptr) {
263 parent_->FinishProcessingHandshakeMessage(client_hello, result); 263 parent_->FinishProcessingHandshakeMessage(client_hello, result);
264 } 264 }
265 } 265 }
266 266
267 } // namespace net 267 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698