| 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/core/quic_crypto_server_stream.h" | 5 #include "net/quic/core/quic_crypto_server_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/base64.h" | |
| 10 #include "crypto/secure_hash.h" | 9 #include "crypto/secure_hash.h" |
| 11 #include "net/quic/core/crypto/crypto_protocol.h" | 10 #include "net/quic/core/crypto/crypto_protocol.h" |
| 12 #include "net/quic/core/crypto/crypto_utils.h" | 11 #include "net/quic/core/crypto/crypto_utils.h" |
| 13 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 12 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
| 14 #include "net/quic/core/crypto/quic_random.h" | 13 #include "net/quic/core/crypto/quic_random.h" |
| 15 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 14 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
| 16 #include "net/quic/core/quic_config.h" | 15 #include "net/quic/core/quic_config.h" |
| 17 #include "net/quic/core/quic_flags.h" | 16 #include "net/quic/core/quic_flags.h" |
| 18 #include "net/quic/core/quic_packets.h" | 17 #include "net/quic/core/quic_packets.h" |
| 19 #include "net/quic/core/quic_session.h" | 18 #include "net/quic/core/quic_session.h" |
| 19 #include "net/quic/platform/api/quic_text_utils.h" |
| 20 | 20 |
| 21 using base::StringPiece; | 21 using base::StringPiece; |
| 22 using std::string; | 22 using std::string; |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 | 25 |
| 26 class QuicCryptoServerStream::ProcessClientHelloCallback | 26 class QuicCryptoServerStream::ProcessClientHelloCallback |
| 27 : public ProcessClientHelloResultCallback { | 27 : public ProcessClientHelloResultCallback { |
| 28 public: | 28 public: |
| 29 ProcessClientHelloCallback( | 29 ProcessClientHelloCallback( |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 return false; | 414 return false; |
| 415 } | 415 } |
| 416 | 416 |
| 417 const string& channel_id(crypto_negotiated_params_->channel_id); | 417 const string& channel_id(crypto_negotiated_params_->channel_id); |
| 418 std::unique_ptr<crypto::SecureHash> hash( | 418 std::unique_ptr<crypto::SecureHash> hash( |
| 419 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 419 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
| 420 hash->Update(channel_id.data(), channel_id.size()); | 420 hash->Update(channel_id.data(), channel_id.size()); |
| 421 uint8_t digest[32]; | 421 uint8_t digest[32]; |
| 422 hash->Finish(digest, sizeof(digest)); | 422 hash->Finish(digest, sizeof(digest)); |
| 423 | 423 |
| 424 base::Base64Encode( | 424 QuicTextUtils::Base64Encode(digest, arraysize(digest), output); |
| 425 string(reinterpret_cast<const char*>(digest), sizeof(digest)), output); | |
| 426 // Remove padding. | |
| 427 size_t len = output->size(); | |
| 428 if (len >= 2) { | |
| 429 if ((*output)[len - 1] == '=') { | |
| 430 len--; | |
| 431 if ((*output)[len - 1] == '=') { | |
| 432 len--; | |
| 433 } | |
| 434 output->resize(len); | |
| 435 } | |
| 436 } | |
| 437 return true; | 425 return true; |
| 438 } | 426 } |
| 439 | 427 |
| 440 void QuicCryptoServerStream::ProcessClientHello( | 428 void QuicCryptoServerStream::ProcessClientHello( |
| 441 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> | 429 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> |
| 442 result, | 430 result, |
| 443 std::unique_ptr<ProofSource::Details> proof_source_details, | 431 std::unique_ptr<ProofSource::Details> proof_source_details, |
| 444 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) { | 432 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) { |
| 445 const CryptoHandshakeMessage& message = result->client_hello; | 433 const CryptoHandshakeMessage& message = result->client_hello; |
| 446 string error_details; | 434 string error_details; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( | 488 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( |
| 501 bool use_stateless_rejects) { | 489 bool use_stateless_rejects) { |
| 502 if (!use_stateless_rejects) { | 490 if (!use_stateless_rejects) { |
| 503 return 0; | 491 return 0; |
| 504 } | 492 } |
| 505 return helper_->GenerateConnectionIdForReject( | 493 return helper_->GenerateConnectionIdForReject( |
| 506 session()->connection()->connection_id()); | 494 session()->connection()->connection_id()); |
| 507 } | 495 } |
| 508 | 496 |
| 509 } // namespace net | 497 } // namespace net |
| OLD | NEW |