| OLD | NEW |
| 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/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
| 10 #include "net/quic/crypto/crypto_utils.h" | 10 #include "net/quic/crypto/crypto_utils.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 const QuicData& data = server_config_update_message.GetSerialized(); | 232 const QuicData& data = server_config_update_message.GetSerialized(); |
| 233 WriteOrBufferData(string(data.data(), data.length()), false, nullptr); | 233 WriteOrBufferData(string(data.data(), data.length()), false, nullptr); |
| 234 | 234 |
| 235 ++num_server_config_update_messages_sent_; | 235 ++num_server_config_update_messages_sent_; |
| 236 } | 236 } |
| 237 | 237 |
| 238 void QuicCryptoServerStream::OnServerHelloAcked() { | 238 void QuicCryptoServerStream::OnServerHelloAcked() { |
| 239 session()->connection()->OnHandshakeComplete(); | 239 session()->connection()->OnHandshakeComplete(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 uint8 QuicCryptoServerStream::NumHandshakeMessages() const { | 242 uint8_t QuicCryptoServerStream::NumHandshakeMessages() const { |
| 243 return num_handshake_messages_; | 243 return num_handshake_messages_; |
| 244 } | 244 } |
| 245 | 245 |
| 246 uint8 QuicCryptoServerStream::NumHandshakeMessagesWithServerNonces() const { | 246 uint8_t QuicCryptoServerStream::NumHandshakeMessagesWithServerNonces() const { |
| 247 return num_handshake_messages_with_server_nonces_; | 247 return num_handshake_messages_with_server_nonces_; |
| 248 } | 248 } |
| 249 | 249 |
| 250 int QuicCryptoServerStream::NumServerConfigUpdateMessagesSent() const { | 250 int QuicCryptoServerStream::NumServerConfigUpdateMessagesSent() const { |
| 251 return num_server_config_update_messages_sent_; | 251 return num_server_config_update_messages_sent_; |
| 252 } | 252 } |
| 253 | 253 |
| 254 const CachedNetworkParameters* | 254 const CachedNetworkParameters* |
| 255 QuicCryptoServerStream::PreviousCachedNetworkParams() const { | 255 QuicCryptoServerStream::PreviousCachedNetworkParams() const { |
| 256 return previous_cached_network_params_.get(); | 256 return previous_cached_network_params_.get(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 279 string* output) const { | 279 string* output) const { |
| 280 if (!encryption_established_ || | 280 if (!encryption_established_ || |
| 281 crypto_negotiated_params_.channel_id.empty()) { | 281 crypto_negotiated_params_.channel_id.empty()) { |
| 282 return false; | 282 return false; |
| 283 } | 283 } |
| 284 | 284 |
| 285 const string& channel_id(crypto_negotiated_params_.channel_id); | 285 const string& channel_id(crypto_negotiated_params_.channel_id); |
| 286 scoped_ptr<crypto::SecureHash> hash( | 286 scoped_ptr<crypto::SecureHash> hash( |
| 287 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 287 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
| 288 hash->Update(channel_id.data(), channel_id.size()); | 288 hash->Update(channel_id.data(), channel_id.size()); |
| 289 uint8 digest[32]; | 289 uint8_t digest[32]; |
| 290 hash->Finish(digest, sizeof(digest)); | 290 hash->Finish(digest, sizeof(digest)); |
| 291 | 291 |
| 292 base::Base64Encode( | 292 base::Base64Encode( |
| 293 string(reinterpret_cast<const char*>(digest), sizeof(digest)), output); | 293 string(reinterpret_cast<const char*>(digest), sizeof(digest)), output); |
| 294 // Remove padding. | 294 // Remove padding. |
| 295 size_t len = output->size(); | 295 size_t len = output->size(); |
| 296 if (len >= 2) { | 296 if (len >= 2) { |
| 297 if ((*output)[len - 1] == '=') { | 297 if ((*output)[len - 1] == '=') { |
| 298 len--; | 298 len--; |
| 299 if ((*output)[len - 1] == '=') { | 299 if ((*output)[len - 1] == '=') { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 373 } |
| 374 for (size_t i = 0; i < received_tags_length; ++i) { | 374 for (size_t i = 0; i < received_tags_length; ++i) { |
| 375 if (received_tags[i] == kSREJ) { | 375 if (received_tags[i] == kSREJ) { |
| 376 return true; | 376 return true; |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 return false; | 379 return false; |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace net | 382 } // namespace net |
| OLD | NEW |