blob: e940635eba89f57df2778e8680df1566d0a20f94 [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
22namespace quic {
23
24const int QuicCryptoClientStream::kMaxClientHellos;
25
26QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session)
27 : QuicCryptoStream(session) {}
28
29QuicCryptoClientStream::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:
vasilvv0fc587f2019-09-06 13:33:08 -070039 handshaker_ = std::make_unique<QuicCryptoClientHandshaker>(
QUICHE teama6ef0a62019-03-07 20:34:33 -050040 server_id, this, session, std::move(verify_context), crypto_config,
41 proof_handler);
42 break;
43 case PROTOCOL_TLS1_3:
vasilvv0fc587f2019-09-06 13:33:08 -070044 handshaker_ = std::make_unique<TlsClientHandshaker>(
nharperdf7a77b2019-11-11 13:12:45 -080045 server_id, this, session, std::move(verify_context), crypto_config,
46 proof_handler);
QUICHE teama6ef0a62019-03-07 20:34:33 -050047 break;
48 case PROTOCOL_UNSUPPORTED:
49 QUIC_BUG << "Attempting to create QuicCryptoClientStream for unknown "
50 "handshake protocol";
51 }
52}
53
54QuicCryptoClientStream::~QuicCryptoClientStream() {}
55
56bool QuicCryptoClientStream::CryptoConnect() {
57 return handshaker_->CryptoConnect();
58}
59
60int QuicCryptoClientStream::num_sent_client_hellos() const {
61 return handshaker_->num_sent_client_hellos();
62}
63
nharper02703962019-11-07 12:23:13 -080064bool QuicCryptoClientStream::IsResumption() const {
65 return handshaker_->IsResumption();
66}
67
QUICHE teama6ef0a62019-03-07 20:34:33 -050068int QuicCryptoClientStream::num_scup_messages_received() const {
69 return handshaker_->num_scup_messages_received();
70}
71
72bool QuicCryptoClientStream::encryption_established() const {
73 return handshaker_->encryption_established();
74}
75
76bool QuicCryptoClientStream::handshake_confirmed() const {
77 return handshaker_->handshake_confirmed();
78}
79
80const QuicCryptoNegotiatedParameters&
81QuicCryptoClientStream::crypto_negotiated_params() const {
82 return handshaker_->crypto_negotiated_params();
83}
84
85CryptoMessageParser* QuicCryptoClientStream::crypto_message_parser() {
86 return handshaker_->crypto_message_parser();
87}
88
nharper486a8a92019-08-28 16:25:10 -070089size_t QuicCryptoClientStream::BufferSizeLimitForLevel(
90 EncryptionLevel level) const {
91 return handshaker_->BufferSizeLimitForLevel(level);
92}
93
vasilvvc48c8712019-03-11 13:38:16 -070094std::string QuicCryptoClientStream::chlo_hash() const {
QUICHE teama6ef0a62019-03-07 20:34:33 -050095 return handshaker_->chlo_hash();
96}
97
98} // namespace quic