blob: fa0f78a51c9ab2e2c168fc74d2f1f8962d92a227 [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_handshaker.h"
6
7#include "net/third_party/quiche/src/quic/core/quic_session.h"
8
9namespace quic {
10
11#define ENDPOINT \
12 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client: ")
13
14QuicCryptoHandshaker::QuicCryptoHandshaker(QuicCryptoStream* stream,
15 QuicSession* session)
16 : stream_(stream), session_(session), last_sent_handshake_message_tag_(0) {
17 crypto_framer_.set_visitor(this);
18}
19
20QuicCryptoHandshaker::~QuicCryptoHandshaker() {}
21
22void QuicCryptoHandshaker::SendHandshakeMessage(
23 const CryptoHandshakeMessage& message) {
24 QUIC_DVLOG(1) << ENDPOINT << "Sending " << message.DebugString();
25 session()->NeuterUnencryptedData();
26 session()->OnCryptoHandshakeMessageSent(message);
27 last_sent_handshake_message_tag_ = message.tag();
28 const QuicData& data = message.GetSerialized();
29 stream_->WriteCryptoData(session_->connection()->encryption_level(),
30 data.AsStringPiece());
31}
32
33void QuicCryptoHandshaker::OnError(CryptoFramer* framer) {
34 QUIC_DLOG(WARNING) << "Error processing crypto data: "
35 << QuicErrorCodeToString(framer->error());
36}
37
38void QuicCryptoHandshaker::OnHandshakeMessage(
39 const CryptoHandshakeMessage& message) {
40 QUIC_DVLOG(1) << ENDPOINT << "Received " << message.DebugString();
41 session()->OnCryptoHandshakeMessageReceived(message);
42}
43
44CryptoMessageParser* QuicCryptoHandshaker::crypto_message_parser() {
45 return &crypto_framer_;
46}
47
48#undef ENDPOINT // undef for jumbo builds
49} // namespace quic