1 /* 2 * Copyright (c) Facebook, Inc. and its affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 * 7 */ 8 9 #pragma once 10 11 #include <quic/fizz/handshake/FizzCryptoFactory.h> 12 #include <quic/server/handshake/ServerHandshake.h> 13 14 #include <fizz/server/ServerProtocol.h> 15 16 namespace quic { 17 18 class FizzServerQuicHandshakeContext; 19 struct QuicServerConnectionState; 20 21 class FizzServerHandshake : public ServerHandshake { 22 public: 23 FizzServerHandshake( 24 QuicServerConnectionState* conn, 25 std::shared_ptr<FizzServerQuicHandshakeContext> fizzContext, 26 std::unique_ptr<CryptoFactory> cryptoFactory); 27 28 const CryptoFactory& getCryptoFactory() const override; 29 30 /** 31 * Returns the context used by the ServerHandshake. 32 */ 33 const fizz::server::FizzServerContext* getContext() const; 34 35 private: 36 void initializeImpl( 37 HandshakeCallback* callback, 38 std::unique_ptr<fizz::server::AppTokenValidator> validator) override; 39 40 EncryptionLevel getReadRecordLayerEncryptionLevel() override; 41 void processSocketData(folly::IOBufQueue& queue) override; 42 std::pair<std::unique_ptr<Aead>, std::unique_ptr<PacketNumberCipher>> 43 buildCiphers(folly::ByteRange secret) override; 44 45 void processAccept() override; 46 bool processPendingCryptoEvent() override; 47 void writeNewSessionTicketToCrypto(const AppToken& appToken) override; 48 49 using PendingEvent = fizz::WriteNewSessionTicket; 50 std::deque<PendingEvent> pendingEvents_; 51 52 std::unique_ptr<FizzCryptoFactory> cryptoFactory_; 53 54 std::shared_ptr<FizzServerQuicHandshakeContext> fizzContext_; 55 }; 56 57 } // namespace quic 58