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 "crypto/secure_hash.h" | |
10 #include "net/quic/core/crypto/crypto_protocol.h" | 9 #include "net/quic/core/crypto/crypto_protocol.h" |
11 #include "net/quic/core/crypto/crypto_utils.h" | 10 #include "net/quic/core/crypto/crypto_utils.h" |
12 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 11 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
13 #include "net/quic/core/crypto/quic_random.h" | 12 #include "net/quic/core/crypto/quic_random.h" |
14 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 13 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
15 #include "net/quic/core/quic_config.h" | 14 #include "net/quic/core/quic_config.h" |
16 #include "net/quic/core/quic_flags.h" | 15 #include "net/quic/core/quic_flags.h" |
17 #include "net/quic/core/quic_packets.h" | 16 #include "net/quic/core/quic_packets.h" |
18 #include "net/quic/core/quic_session.h" | 17 #include "net/quic/core/quic_session.h" |
19 #include "net/quic/platform/api/quic_logging.h" | 18 #include "net/quic/platform/api/quic_logging.h" |
20 #include "net/quic/platform/api/quic_text_utils.h" | 19 #include "net/quic/platform/api/quic_text_utils.h" |
| 20 #include "third_party/boringssl/src/include/openssl/sha.h" |
21 | 21 |
22 using base::StringPiece; | 22 using base::StringPiece; |
23 using std::string; | 23 using std::string; |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 | 26 |
27 class QuicCryptoServerStream::ProcessClientHelloCallback | 27 class QuicCryptoServerStream::ProcessClientHelloCallback |
28 : public ProcessClientHelloResultCallback { | 28 : public ProcessClientHelloResultCallback { |
29 public: | 29 public: |
30 ProcessClientHelloCallback( | 30 ProcessClientHelloCallback( |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 410 } |
411 | 411 |
412 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID( | 412 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID( |
413 string* output) const { | 413 string* output) const { |
414 if (!encryption_established_ || | 414 if (!encryption_established_ || |
415 crypto_negotiated_params_->channel_id.empty()) { | 415 crypto_negotiated_params_->channel_id.empty()) { |
416 return false; | 416 return false; |
417 } | 417 } |
418 | 418 |
419 const string& channel_id(crypto_negotiated_params_->channel_id); | 419 const string& channel_id(crypto_negotiated_params_->channel_id); |
420 std::unique_ptr<crypto::SecureHash> hash( | 420 uint8_t digest[SHA256_DIGEST_LENGTH]; |
421 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 421 SHA256(reinterpret_cast<const uint8_t*>(channel_id.data()), channel_id.size(), |
422 hash->Update(channel_id.data(), channel_id.size()); | 422 digest); |
423 uint8_t digest[32]; | |
424 hash->Finish(digest, sizeof(digest)); | |
425 | 423 |
426 QuicTextUtils::Base64Encode(digest, arraysize(digest), output); | 424 QuicTextUtils::Base64Encode(digest, arraysize(digest), output); |
427 return true; | 425 return true; |
428 } | 426 } |
429 | 427 |
430 void QuicCryptoServerStream::ProcessClientHello( | 428 void QuicCryptoServerStream::ProcessClientHello( |
431 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> | 429 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> |
432 result, | 430 result, |
433 std::unique_ptr<ProofSource::Details> proof_source_details, | 431 std::unique_ptr<ProofSource::Details> proof_source_details, |
434 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) { | 432 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( | 488 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( |
491 bool use_stateless_rejects) { | 489 bool use_stateless_rejects) { |
492 if (!use_stateless_rejects) { | 490 if (!use_stateless_rejects) { |
493 return 0; | 491 return 0; |
494 } | 492 } |
495 return helper_->GenerateConnectionIdForReject( | 493 return helper_->GenerateConnectionIdForReject( |
496 session()->connection()->connection_id()); | 494 session()->connection()->connection_id()); |
497 } | 495 } |
498 | 496 |
499 } // namespace net | 497 } // namespace net |
OLD | NEW |