blob: b30cd3a511219d88082e309867db9ea455618d93 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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>
vasilvv872e7a32019-03-12 16:42:44 -07008#include <string>
bnc463f2352019-10-10 04:49:34 -07009#include <utility>
QUICHE teama6ef0a62019-03-07 20:34:33 -050010
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 teama6ef0a62019-03-07 20:34:33 -050021#include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050022
23namespace quic {
24
25const int QuicCryptoClientStream::kMaxClientHellos;
26
27QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session)
28 : QuicCryptoStream(session) {}
29
30QuicCryptoClientStream::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:
vasilvv0fc587f2019-09-06 13:33:08 -070040 handshaker_ = std::make_unique<QuicCryptoClientHandshaker>(
QUICHE teama6ef0a62019-03-07 20:34:33 -050041 server_id, this, session, std::move(verify_context), crypto_config,
42 proof_handler);
43 break;
44 case PROTOCOL_TLS1_3:
vasilvv0fc587f2019-09-06 13:33:08 -070045 handshaker_ = std::make_unique<TlsClientHandshaker>(
nharperdf7a77b2019-11-11 13:12:45 -080046 server_id, this, session, std::move(verify_context), crypto_config,
47 proof_handler);
QUICHE teama6ef0a62019-03-07 20:34:33 -050048 break;
49 case PROTOCOL_UNSUPPORTED:
50 QUIC_BUG << "Attempting to create QuicCryptoClientStream for unknown "
51 "handshake protocol";
52 }
53}
54
55QuicCryptoClientStream::~QuicCryptoClientStream() {}
56
57bool QuicCryptoClientStream::CryptoConnect() {
58 return handshaker_->CryptoConnect();
59}
60
61int QuicCryptoClientStream::num_sent_client_hellos() const {
62 return handshaker_->num_sent_client_hellos();
63}
64
nharper02703962019-11-07 12:23:13 -080065bool QuicCryptoClientStream::IsResumption() const {
66 return handshaker_->IsResumption();
67}
68
QUICHE teama6ef0a62019-03-07 20:34:33 -050069int QuicCryptoClientStream::num_scup_messages_received() const {
70 return handshaker_->num_scup_messages_received();
71}
72
73bool QuicCryptoClientStream::encryption_established() const {
74 return handshaker_->encryption_established();
75}
76
77bool QuicCryptoClientStream::handshake_confirmed() const {
78 return handshaker_->handshake_confirmed();
79}
80
81const QuicCryptoNegotiatedParameters&
82QuicCryptoClientStream::crypto_negotiated_params() const {
83 return handshaker_->crypto_negotiated_params();
84}
85
86CryptoMessageParser* QuicCryptoClientStream::crypto_message_parser() {
87 return handshaker_->crypto_message_parser();
88}
89
nharper486a8a92019-08-28 16:25:10 -070090size_t QuicCryptoClientStream::BufferSizeLimitForLevel(
91 EncryptionLevel level) const {
92 return handshaker_->BufferSizeLimitForLevel(level);
93}
94
vasilvvc48c8712019-03-11 13:38:16 -070095std::string QuicCryptoClientStream::chlo_hash() const {
QUICHE teama6ef0a62019-03-07 20:34:33 -050096 return handshaker_->chlo_hash();
97}
98
99} // namespace quic