QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" |
| 6 | |
| 7 | #include <memory> |
vasilvv | 872e7a3 | 2019-03-12 16:42:44 -0700 | [diff] [blame] | 8 | #include <string> |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 9 | |
| 10 | #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" |
| 11 | #include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" |
| 12 | #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" |
| 13 | #include "net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h" |
| 14 | #include "net/third_party/quiche/src/quic/core/quic_packets.h" |
| 15 | #include "net/third_party/quiche/src/quic/core/quic_session.h" |
| 16 | #include "net/third_party/quiche/src/quic/core/quic_utils.h" |
| 17 | #include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" |
| 18 | #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" |
| 19 | #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" |
| 20 | #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" |
| 21 | #include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 22 | |
| 23 | namespace quic { |
| 24 | |
| 25 | const int QuicCryptoClientStream::kMaxClientHellos; |
| 26 | |
| 27 | QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session) |
| 28 | : QuicCryptoStream(session) {} |
| 29 | |
| 30 | QuicCryptoClientStream::QuicCryptoClientStream( |
| 31 | const QuicServerId& server_id, |
| 32 | QuicSession* session, |
| 33 | std::unique_ptr<ProofVerifyContext> verify_context, |
| 34 | QuicCryptoClientConfig* crypto_config, |
| 35 | ProofHandler* proof_handler) |
| 36 | : QuicCryptoClientStreamBase(session) { |
| 37 | DCHECK_EQ(Perspective::IS_CLIENT, session->connection()->perspective()); |
| 38 | switch (session->connection()->version().handshake_protocol) { |
| 39 | case PROTOCOL_QUIC_CRYPTO: |
| 40 | handshaker_ = QuicMakeUnique<QuicCryptoClientHandshaker>( |
| 41 | server_id, this, session, std::move(verify_context), crypto_config, |
| 42 | proof_handler); |
| 43 | break; |
| 44 | case PROTOCOL_TLS1_3: |
| 45 | handshaker_ = QuicMakeUnique<TlsClientHandshaker>( |
| 46 | this, session, server_id, crypto_config->proof_verifier(), |
| 47 | crypto_config->ssl_ctx(), std::move(verify_context), |
| 48 | crypto_config->user_agent_id()); |
| 49 | break; |
| 50 | case PROTOCOL_UNSUPPORTED: |
| 51 | QUIC_BUG << "Attempting to create QuicCryptoClientStream for unknown " |
| 52 | "handshake protocol"; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | QuicCryptoClientStream::~QuicCryptoClientStream() {} |
| 57 | |
| 58 | bool QuicCryptoClientStream::CryptoConnect() { |
| 59 | return handshaker_->CryptoConnect(); |
| 60 | } |
| 61 | |
| 62 | int QuicCryptoClientStream::num_sent_client_hellos() const { |
| 63 | return handshaker_->num_sent_client_hellos(); |
| 64 | } |
| 65 | |
| 66 | int QuicCryptoClientStream::num_scup_messages_received() const { |
| 67 | return handshaker_->num_scup_messages_received(); |
| 68 | } |
| 69 | |
| 70 | bool QuicCryptoClientStream::encryption_established() const { |
| 71 | return handshaker_->encryption_established(); |
| 72 | } |
| 73 | |
| 74 | bool QuicCryptoClientStream::handshake_confirmed() const { |
| 75 | return handshaker_->handshake_confirmed(); |
| 76 | } |
| 77 | |
| 78 | const QuicCryptoNegotiatedParameters& |
| 79 | QuicCryptoClientStream::crypto_negotiated_params() const { |
| 80 | return handshaker_->crypto_negotiated_params(); |
| 81 | } |
| 82 | |
| 83 | CryptoMessageParser* QuicCryptoClientStream::crypto_message_parser() { |
| 84 | return handshaker_->crypto_message_parser(); |
| 85 | } |
| 86 | |
vasilvv | c48c871 | 2019-03-11 13:38:16 -0700 | [diff] [blame] | 87 | std::string QuicCryptoClientStream::chlo_hash() const { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 88 | return handshaker_->chlo_hash(); |
| 89 | } |
| 90 | |
| 91 | } // namespace quic |