proxygen
fizz::Factory Class Reference

#include <Factory.h>

Inheritance diagram for fizz::Factory:
fizz::JavaCryptoFactory fizz::LoggingFactory fizz::test::MockFactory

Public Member Functions

virtual ~Factory ()=default
 
virtual std::unique_ptr< PlaintextReadRecordLayermakePlaintextReadRecordLayer () const
 
virtual std::unique_ptr< PlaintextWriteRecordLayermakePlaintextWriteRecordLayer () const
 
virtual std::unique_ptr< EncryptedReadRecordLayermakeEncryptedReadRecordLayer (EncryptionLevel encryptionLevel) const
 
virtual std::unique_ptr< EncryptedWriteRecordLayermakeEncryptedWriteRecordLayer (EncryptionLevel encryptionLevel) const
 
virtual std::unique_ptr< KeySchedulermakeKeyScheduler (CipherSuite cipher) const
 
virtual std::unique_ptr< KeyDerivationmakeKeyDeriver (CipherSuite cipher) const
 
virtual std::unique_ptr< HandshakeContextmakeHandshakeContext (CipherSuite cipher) const
 
virtual std::unique_ptr< KeyExchangemakeKeyExchange (NamedGroup group) const
 
virtual std::unique_ptr< AeadmakeAead (CipherSuite cipher) const
 
virtual Random makeRandom () const
 
virtual uint32_t makeTicketAgeAdd () const
 
virtual std::shared_ptr< PeerCertmakePeerCert (Buf certData) const
 
virtual std::string getHkdfPrefix () const
 

Detailed Description

This class instantiates various objects to facilitate testing.

Definition at line 32 of file Factory.h.

Constructor & Destructor Documentation

virtual fizz::Factory::~Factory ( )
virtualdefault

Member Function Documentation

virtual std::string fizz::Factory::getHkdfPrefix ( ) const
inlinevirtual

Definition at line 132 of file Factory.h.

References fizz::kHkdfLabelPrefix, and folly::Range< Iter >::str().

Referenced by makeHandshakeContext(), and makeKeyDeriver().

132  {
133  return kHkdfLabelPrefix.str();
134  }
std::string str() const
Definition: Range.h:591
constexpr folly::StringPiece kHkdfLabelPrefix
Definition: Types.h:20
virtual std::unique_ptr<Aead> fizz::Factory::makeAead ( CipherSuite  cipher) const
inlinevirtual

Definition at line 105 of file Factory.h.

References fizz::TLS_AES_128_GCM_SHA256, fizz::TLS_AES_128_OCB_SHA256_EXPERIMENTAL, fizz::TLS_AES_256_GCM_SHA384, and fizz::TLS_CHACHA20_POLY1305_SHA256.

Referenced by fizz::Protocol::setAead().

105  {
106  switch (cipher) {
108  return std::make_unique<OpenSSLEVPCipher<ChaCha20Poly1305>>();
110  return std::make_unique<OpenSSLEVPCipher<AESGCM128>>();
112  return std::make_unique<OpenSSLEVPCipher<AESGCM256>>();
114  return std::make_unique<OpenSSLEVPCipher<AESOCB128>>();
115  default:
116  throw std::runtime_error("aead: not implemented");
117  }
118  }
CipherSuite cipher
virtual std::unique_ptr<EncryptedReadRecordLayer> fizz::Factory::makeEncryptedReadRecordLayer ( EncryptionLevel  encryptionLevel) const
inlinevirtual

Definition at line 47 of file Factory.h.

Referenced by fizz::sm::generateTicket(), fizz::sm::getCertificateRequest(), fizz::sm::getMaxEarlyDataSize(), fizz::sm::handleCertMsg(), and fizz::sm::negotiatePsk().

47  {
48  return std::make_unique<EncryptedReadRecordLayer>(encryptionLevel);
49  }
virtual std::unique_ptr<EncryptedWriteRecordLayer> fizz::Factory::makeEncryptedWriteRecordLayer ( EncryptionLevel  encryptionLevel) const
inlinevirtual

Definition at line 52 of file Factory.h.

Referenced by fizz::sm::generateTicket(), fizz::sm::getCertificateRequest(), fizz::sm::getMaxEarlyDataSize(), fizz::sm::handleCertMsg(), and fizz::sm::negotiatePsk().

52  {
53  return std::make_unique<EncryptedWriteRecordLayer>(encryptionLevel);
54  }
virtual std::unique_ptr<HandshakeContext> fizz::Factory::makeHandshakeContext ( CipherSuite  cipher) const
inlinevirtual
virtual std::unique_ptr<KeyExchange> fizz::Factory::makeKeyExchange ( NamedGroup  group) const
inlinevirtual

Definition at line 90 of file Factory.h.

References fizz::secp256r1, fizz::secp384r1, fizz::secp521r1, and fizz::x25519.

Referenced by fizz::sm::doKex(), and fizz::sm::getKeyExchangers().

90  {
91  switch (group) {
93  return std::make_unique<OpenSSLKeyExchange<P256>>();
95  return std::make_unique<OpenSSLKeyExchange<P384>>();
97  return std::make_unique<OpenSSLKeyExchange<P521>>();
98  case NamedGroup::x25519:
99  return std::make_unique<X25519KeyExchange>();
100  default:
101  throw std::runtime_error("ke: not implemented");
102  }
103  }
Optional< NamedGroup > group
virtual std::unique_ptr<KeyScheduler> fizz::Factory::makeKeyScheduler ( CipherSuite  cipher) const
inlinevirtual

Reimplemented in fizz::LoggingFactory.

Definition at line 56 of file Factory.h.

References makeKeyDeriver(), and folly::gen::move.

Referenced by fizz::sm::getHrrKeyExchangers(), fizz::sm::negotiatePsk(), and fizz::sm::setupSchedulerAndContext().

57  {
58  auto keyDer = makeKeyDeriver(cipher);
59  return std::make_unique<KeyScheduler>(std::move(keyDer));
60  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
CipherSuite cipher
virtual std::unique_ptr< KeyDerivation > makeKeyDeriver(CipherSuite cipher) const
Definition: Factory.h:62
virtual std::shared_ptr<PeerCert> fizz::Factory::makePeerCert ( Buf  certData) const
inlinevirtual

Reimplemented in fizz::test::MockFactory, and fizz::JavaCryptoFactory.

Definition at line 128 of file Factory.h.

References fizz::CertUtils::makePeerCert(), and folly::gen::move.

Referenced by fizz::sm::generateTicket(), and fizz::sm::handleCertMsg().

128  {
129  return CertUtils::makePeerCert(std::move(certData));
130  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static std::unique_ptr< PeerCert > makePeerCert(Buf certData)
Definition: Certificate.cpp:87
virtual std::unique_ptr<PlaintextReadRecordLayer> fizz::Factory::makePlaintextReadRecordLayer ( ) const
inlinevirtual

Definition at line 37 of file Factory.h.

Referenced by fizz::sm::getCertificateRequest().

37  {
38  return std::make_unique<PlaintextReadRecordLayer>();
39  }
virtual std::unique_ptr<PlaintextWriteRecordLayer> fizz::Factory::makePlaintextWriteRecordLayer ( ) const
inlinevirtual

Definition at line 42 of file Factory.h.

42  {
43  return std::make_unique<PlaintextWriteRecordLayer>();
44  }
virtual Random fizz::Factory::makeRandom ( ) const
inlinevirtual

Definition at line 120 of file Factory.h.

Referenced by fizz::sm::getCertificateRequest().

120  {
121  return RandomGenerator<Random().size()>().generateRandom();
122  }
std::array< uint8_t, 32 > Random
Definition: Types.h:184
virtual uint32_t fizz::Factory::makeTicketAgeAdd ( ) const
inlinevirtual

Definition at line 124 of file Factory.h.

Referenced by fizz::sm::generateTicket().

124  {
125  return RandomNumGenerator<uint32_t>().generateRandom();
126  }

The documentation for this class was generated from the following file: