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