QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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_SERVER_STREAM_H_ |
| 6 | #define QUICHE_QUIC_CORE_QUIC_CRYPTO_SERVER_STREAM_H_ |
| 7 | |
| 8 | #include <cstdint> |
| 9 | #include <memory> |
vasilvv | 872e7a3 | 2019-03-12 16:42:44 -0700 | [diff] [blame] | 10 | #include <string> |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 11 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 12 | #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" |
| 13 | #include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" |
| 14 | #include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" |
| 15 | #include "net/third_party/quiche/src/quic/core/quic_config.h" |
| 16 | #include "net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h" |
| 17 | #include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" |
| 18 | #include "net/third_party/quiche/src/quic/core/quic_session.h" |
| 19 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 20 | |
| 21 | namespace quic { |
| 22 | |
| 23 | class CachedNetworkParameters; |
| 24 | class CryptoHandshakeMessage; |
| 25 | class QuicCryptoServerConfig; |
| 26 | class QuicCryptoServerStreamBase; |
| 27 | |
| 28 | // TODO(alyssar) see what can be moved out of QuicCryptoServerStream with |
| 29 | // various code and test refactoring. |
| 30 | class QUIC_EXPORT_PRIVATE QuicCryptoServerStreamBase : public QuicCryptoStream { |
| 31 | public: |
| 32 | explicit QuicCryptoServerStreamBase(QuicSession* session); |
| 33 | |
nharper | 5f23a2d | 2020-02-20 10:44:09 -0800 | [diff] [blame] | 34 | class QUIC_EXPORT_PRIVATE Helper { |
| 35 | public: |
| 36 | virtual ~Helper() {} |
| 37 | |
| 38 | // Returns true if |message|, which was received on |self_address| is |
| 39 | // acceptable according to the visitor's policy. Otherwise, returns false |
| 40 | // and populates |error_details|. |
| 41 | virtual bool CanAcceptClientHello(const CryptoHandshakeMessage& message, |
| 42 | const QuicSocketAddress& client_address, |
| 43 | const QuicSocketAddress& peer_address, |
| 44 | const QuicSocketAddress& self_address, |
| 45 | std::string* error_details) const = 0; |
| 46 | }; |
| 47 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 48 | ~QuicCryptoServerStreamBase() override {} |
| 49 | |
| 50 | // Cancel any outstanding callbacks, such as asynchronous validation of client |
| 51 | // hello. |
| 52 | virtual void CancelOutstandingCallbacks() = 0; |
| 53 | |
| 54 | // GetBase64SHA256ClientChannelID sets |*output| to the base64 encoded, |
| 55 | // SHA-256 hash of the client's ChannelID key and returns true, if the client |
| 56 | // presented a ChannelID. Otherwise it returns false. |
vasilvv | c48c871 | 2019-03-11 13:38:16 -0700 | [diff] [blame] | 57 | virtual bool GetBase64SHA256ClientChannelID(std::string* output) const = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 58 | |
| 59 | virtual int NumServerConfigUpdateMessagesSent() const = 0; |
| 60 | |
| 61 | // Sends the latest server config and source-address token to the client. |
| 62 | virtual void SendServerConfigUpdate( |
| 63 | const CachedNetworkParameters* cached_network_params) = 0; |
| 64 | |
| 65 | // These are all accessors and setters to their respective counters. |
| 66 | virtual uint8_t NumHandshakeMessages() const = 0; |
| 67 | virtual uint8_t NumHandshakeMessagesWithServerNonces() const = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 68 | virtual bool ZeroRttAttempted() const = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 69 | virtual const CachedNetworkParameters* PreviousCachedNetworkParams() |
| 70 | const = 0; |
| 71 | virtual void SetPreviousCachedNetworkParams( |
| 72 | CachedNetworkParameters cached_network_params) = 0; |
nharper | 23d4074 | 2020-01-03 14:55:01 -0800 | [diff] [blame] | 73 | |
| 74 | // NOTE: Indicating that the Expect-CT header should be sent here presents |
| 75 | // a layering violation to some extent. The Expect-CT header only applies to |
| 76 | // HTTP connections, while this class can be used for non-HTTP applications. |
| 77 | // However, it is exposed here because that is the only place where the |
| 78 | // configuration for the certificate used in the connection is accessible. |
| 79 | virtual bool ShouldSendExpectCTHeader() const = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 80 | }; |
| 81 | |
nharper | e5e28f9 | 2020-01-03 14:10:07 -0800 | [diff] [blame] | 82 | // Creates an appropriate QuicCryptoServerStream for the provided parameters, |
| 83 | // including the version used by |session|. |crypto_config|, |session|, and |
| 84 | // |helper| must all outlive the stream. The caller takes ownership of the |
| 85 | // returned object. |
ianswett | 1f4fe2d | 2020-01-10 13:01:17 -0800 | [diff] [blame] | 86 | QUIC_EXPORT_PRIVATE std::unique_ptr<QuicCryptoServerStreamBase> |
| 87 | CreateCryptoServerStream(const QuicCryptoServerConfig* crypto_config, |
| 88 | QuicCompressedCertsCache* compressed_certs_cache, |
| 89 | QuicSession* session, |
nharper | 5f23a2d | 2020-02-20 10:44:09 -0800 | [diff] [blame] | 90 | QuicCryptoServerStreamBase::Helper* helper); |
nharper | e5e28f9 | 2020-01-03 14:10:07 -0800 | [diff] [blame] | 91 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 92 | } // namespace quic |
| 93 | |
| 94 | #endif // QUICHE_QUIC_CORE_QUIC_CRYPTO_SERVER_STREAM_H_ |