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/QuicFizzFactory.h>
12 #include <quic/handshake/CryptoFactory.h>
13 
14 namespace quic {
15 
16 class FizzCryptoFactory : public CryptoFactory {
17  public:
FizzCryptoFactory()18   FizzCryptoFactory() : fizzFactory_{std::make_shared<QuicFizzFactory>()} {}
19 
20   Buf makeInitialTrafficSecret(
21       folly::StringPiece label,
22       const ConnectionId& clientDestinationConnId,
23       QuicVersion version) const override;
24 
25   std::unique_ptr<Aead> makeInitialAead(
26       folly::StringPiece label,
27       const ConnectionId& clientDestinationConnId,
28       QuicVersion version) const override;
29 
30   std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
31       folly::ByteRange baseSecret) const override;
32 
33   virtual std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
34       fizz::CipherSuite cipher) const;
35 
getFizzFactory()36   std::shared_ptr<fizz::Factory> getFizzFactory() {
37     return fizzFactory_;
38   }
39 
40  protected:
41   std::shared_ptr<fizz::Factory> fizzFactory_;
42 };
43 
44 } // namespace quic
45