blob: 93f2a61104aece42f5c567773ce133c3ed1a1395 [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>
QUICHE teama6ef0a62019-03-07 20:34:33 -05009
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 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:
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
56QuicCryptoClientStream::~QuicCryptoClientStream() {}
57
58bool QuicCryptoClientStream::CryptoConnect() {
59 return handshaker_->CryptoConnect();
60}
61
62int QuicCryptoClientStream::num_sent_client_hellos() const {
63 return handshaker_->num_sent_client_hellos();
64}
65
66int QuicCryptoClientStream::num_scup_messages_received() const {
67 return handshaker_->num_scup_messages_received();
68}
69
70bool QuicCryptoClientStream::encryption_established() const {
71 return handshaker_->encryption_established();
72}
73
74bool QuicCryptoClientStream::handshake_confirmed() const {
75 return handshaker_->handshake_confirmed();
76}
77
78const QuicCryptoNegotiatedParameters&
79QuicCryptoClientStream::crypto_negotiated_params() const {
80 return handshaker_->crypto_negotiated_params();
81}
82
83CryptoMessageParser* QuicCryptoClientStream::crypto_message_parser() {
84 return handshaker_->crypto_message_parser();
85}
86
vasilvvc48c8712019-03-11 13:38:16 -070087std::string QuicCryptoClientStream::chlo_hash() const {
QUICHE teama6ef0a62019-03-07 20:34:33 -050088 return handshaker_->chlo_hash();
89}
90
91} // namespace quic