xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/core/quic_crypto_handshaker.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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 #ifndef QUICHE_QUIC_CORE_QUIC_CRYPTO_HANDSHAKER_H_
6 #define QUICHE_QUIC_CORE_QUIC_CRYPTO_HANDSHAKER_H_
7 
8 #include "quiche/quic/core/quic_crypto_stream.h"
9 #include "quiche/quic/platform/api/quic_export.h"
10 
11 namespace quic {
12 
13 class QUICHE_EXPORT QuicCryptoHandshaker : public CryptoFramerVisitorInterface {
14  public:
15   QuicCryptoHandshaker(QuicCryptoStream* stream, QuicSession* session);
16   QuicCryptoHandshaker(const QuicCryptoHandshaker&) = delete;
17   QuicCryptoHandshaker& operator=(const QuicCryptoHandshaker&) = delete;
18 
19   ~QuicCryptoHandshaker() override;
20 
21   // Sends |message| to the peer.
22   // TODO(wtc): return a success/failure status.
23   void SendHandshakeMessage(const CryptoHandshakeMessage& message,
24                             EncryptionLevel level);
25 
26   void OnError(CryptoFramer* framer) override;
27   void OnHandshakeMessage(const CryptoHandshakeMessage& message) override;
28 
29   CryptoMessageParser* crypto_message_parser();
30   size_t BufferSizeLimitForLevel(EncryptionLevel level) const;
31 
32  protected:
last_sent_handshake_message_tag()33   QuicTag last_sent_handshake_message_tag() const {
34     return last_sent_handshake_message_tag_;
35   }
36 
37  private:
session()38   QuicSession* session() { return session_; }
39 
40   QuicCryptoStream* stream_;
41   QuicSession* session_;
42 
43   CryptoFramer crypto_framer_;
44 
45   // Records last sent crypto handshake message tag.
46   QuicTag last_sent_handshake_message_tag_;
47 };
48 
49 }  // namespace quic
50 
51 #endif  // QUICHE_QUIC_CORE_QUIC_CRYPTO_HANDSHAKER_H_
52