proxygen
fizz Namespace Reference

Namespaces

 client
 
 detail
 
 extensions
 
 jni
 
 server
 
 sm
 
 test
 
 testing
 
 tool
 

Classes

struct  Accept
 
class  Aead
 
struct  AESGCM128
 
struct  AESGCM256
 
struct  AESOCB128
 
struct  Alert
 
struct  AppClose
 
struct  AppData
 
struct  AppWrite
 
class  AsyncFizzBase
 
class  AsyncSelfCert
 
class  CertDecompressionManager
 
struct  CertificateAuthorities
 
struct  CertificateCompressionAlgorithms
 
class  CertificateCompressor
 
class  CertificateDecompressor
 
struct  CertificateEntry
 
struct  CertificateMsg
 
struct  CertificateRequest
 
class  CertificateVerifier
 
struct  CertificateVerify
 
class  CertUtils
 
struct  ChaCha20Poly1305
 
struct  ClientEarlyData
 
class  ClientExtensions
 
struct  ClientHello
 
struct  ClientKeyShare
 
struct  ClientPresharedKey
 
struct  CompressedCertificate
 
struct  Connect
 
struct  Cookie
 
struct  CryptoUtils
 
class  DefaultCertificateVerifier
 
struct  DeliverAppData
 
struct  DistinguishedName
 
struct  EarlyAppWrite
 
struct  EncryptedExtensions
 
class  EncryptedReadRecordLayer
 
class  EncryptedWriteRecordLayer
 
struct  EndOfEarlyData
 
struct  EventType
 
class  EventVisitor
 
class  ExportedAuthenticator
 
class  Exporter
 
struct  Extension
 
class  Factory
 
struct  Finished
 
class  FizzBase
 
class  FizzException
 
class  FizzUtil
 
class  FizzVerificationException
 
class  HandshakeContext
 
class  HandshakeContextImpl
 
struct  HandshakeStruct
 
struct  HelloRetryRequest
 
struct  HelloRetryRequestKeyShare
 
class  Hkdf
 
class  HkdfImpl
 
struct  HkdfLabel
 
class  Hmac
 
class  HmacImpl
 
class  IdentityCert
 
class  JavaCryptoCertificateVerifier
 
class  JavaCryptoFactory
 
class  JavaCryptoPeerCert
 
class  KeyDerivation
 
class  KeyDerivationImpl
 
class  KeyExchange
 
class  KeyScheduler
 
struct  KeyShareEntry
 
struct  KeyUpdate
 
class  LoggingFactory
 
class  LoggingKeyScheduler
 
struct  message_hash
 
class  MockEncryptedReadRecordLayer
 
class  MockEncryptedWriteRecordLayer
 
class  MockKeyDerivation
 
class  MockKeyExchange
 
class  MockPlaintextReadRecordLayer
 
class  MockPlaintextWriteRecordLayer
 
struct  NewSessionTicket
 
class  OpenSSLEVPCipher
 
class  OpenSSLKeyExchange
 
class  OpenSSLSignature
 
struct  P256
 
struct  P384
 
struct  P521
 
class  PeerCert
 
class  PeerCertImpl
 
class  PlaintextReadRecordLayer
 
class  PlaintextWriteRecordLayer
 
class  Protocol
 
struct  ProtocolName
 
struct  ProtocolNameList
 
struct  PskBinder
 
struct  PskIdentity
 
struct  PskKeyExchangeModes
 
struct  RandomGenerator
 
struct  RandomNumGenerator
 
class  ReadRecordLayer
 
struct  ReportError
 
class  SelfCert
 
class  SelfCertImpl
 
struct  ServerEarlyData
 
class  ServerExtensions
 
struct  ServerHello
 
struct  ServerKeyShare
 
struct  ServerName
 
struct  ServerNameList
 
struct  ServerPresharedKey
 
struct  ServerSupportedVersions
 
struct  Sha
 
struct  Sha256
 
struct  Sha384
 
struct  SigAlg
 
struct  SigAlg< SignatureScheme::ecdsa_secp256r1_sha256 >
 
struct  SigAlg< SignatureScheme::ecdsa_secp384r1_sha384 >
 
struct  SigAlg< SignatureScheme::ecdsa_secp521r1_sha512 >
 
struct  SigAlg< SignatureScheme::rsa_pss_sha256 >
 
struct  SignatureAlgorithms
 
struct  STACK_OF_X509_deleter
 
struct  SupportedGroups
 
struct  SupportedVersions
 
struct  TicketEarlyData
 
struct  TLSContent
 
struct  TLSMessage
 
struct  TrafficKey
 
struct  WaitForData
 
struct  WriteNewSessionTicket
 
class  WriteRecordLayer
 
struct  WriteToSocket
 
class  X25519KeyExchange
 
class  ZlibCertificateCompressor
 
class  ZlibCertificateDecompressor
 

Typedefs

using P256KeyExchange = detail::OpenSSLECKeyExchange< P256 >
 
using P256PublicKeyDecoder = detail::OpenSSLECKeyDecoder< P256 >
 
using P256PublicKeyEncoder = detail::OpenSSLECKeyEncoder
 
using P384KeyExchange = detail::OpenSSLECKeyExchange< P384 >
 
using P384PublicKeyDecoder = detail::OpenSSLECKeyDecoder< P384 >
 
using P384PublicKeyEncoder = detail::OpenSSLECKeyEncoder
 
using P521KeyExchange = detail::OpenSSLECKeyExchange< P521 >
 
using P521PublicKeyDecoder = detail::OpenSSLECKeyDecoder< P521 >
 
using P521PublicKeyEncoder = detail::OpenSSLECKeyEncoder
 
using Cert = folly::AsyncTransportCertificate
 
using Param = boost::variant< ClientHello, ServerHello, EndOfEarlyData, HelloRetryRequest, EncryptedExtensions, CertificateRequest, CompressedCertificate, CertificateMsg, CertificateVerify, Finished, NewSessionTicket, KeyUpdate, Alert, Accept, Connect, AppData, AppWrite, EarlyAppWrite, WriteNewSessionTicket >
 
using ContentTypeType = typename std::underlying_type< ContentType >::type
 
using ProtocolVersionType = typename std::underlying_type< ProtocolVersion >::type
 
using HandshakeTypeType = typename std::underlying_type< HandshakeType >::type
 
using Buf = std::unique_ptr< folly::IOBuf >
 
using Random = std::array< uint8_t, 32 >
 

Enumerations

enum  KeyType { KeyType::RSA, KeyType::P256, KeyType::P384, KeyType::P521 }
 
enum  Direction : uint8_t { Direction::UPSTREAM, Direction::DOWNSTREAM }
 
enum  VerificationContext { VerificationContext::Client, VerificationContext::Server, VerificationContext::Client, VerificationContext::Server }
 
enum  CertificateVerifyContext { CertificateVerifyContext::Server, CertificateVerifyContext::Client, CertificateVerifyContext::Authenticator }
 
enum  VerificationContext { VerificationContext::Client, VerificationContext::Server, VerificationContext::Client, VerificationContext::Server }
 
enum  Event {
  Event::ClientHello, Event::ServerHello, Event::EndOfEarlyData, Event::HelloRetryRequest,
  Event::EncryptedExtensions, Event::CertificateRequest, Event::Certificate, Event::CompressedCertificate,
  Event::CertificateVerify, Event::Finished, Event::NewSessionTicket, Event::KeyUpdate,
  Event::Alert, Event::Accept, Event::Connect, Event::AppData,
  Event::EarlyAppWrite, Event::AppWrite, Event::AppClose, Event::WriteNewSessionTicket,
  Event::NUM_EVENTS
}
 
enum  EarlySecrets { EarlySecrets::ExternalPskBinder, EarlySecrets::ResumptionPskBinder, EarlySecrets::ClientEarlyTraffic, EarlySecrets::EarlyExporter }
 
enum  HandshakeSecrets { HandshakeSecrets::ClientHandshakeTraffic, HandshakeSecrets::ServerHandshakeTraffic }
 
enum  MasterSecrets { MasterSecrets::ExporterMaster, MasterSecrets::ResumptionMaster }
 
enum  AppTrafficSecrets { AppTrafficSecrets::ClientAppTraffic, AppTrafficSecrets::ServerAppTraffic }
 
enum  HashFunction { HashFunction::Sha256, HashFunction::Sha384 }
 
enum  PskType {
  PskType::NotSupported, PskType::NotAttempted, PskType::Rejected, PskType::External,
  PskType::Resumption
}
 
enum  EncryptionLevel { EncryptionLevel::Plaintext, EncryptionLevel::Handshake, EncryptionLevel::EarlyData, EncryptionLevel::AppTraffic }
 
enum  KeyExchangeType { KeyExchangeType::None, KeyExchangeType::OneRtt, KeyExchangeType::HelloRetryRequest }
 
enum  EarlyDataType { EarlyDataType::NotAttempted, EarlyDataType::Attempted, EarlyDataType::Rejected, EarlyDataType::Accepted }
 
enum  ServerNameType : uint8_t { ServerNameType::host_name = 0 }
 
enum  ProtocolVersion : uint16_t {
  ProtocolVersion::tls_1_0 = 0x0301, ProtocolVersion::tls_1_1 = 0x0302, ProtocolVersion::tls_1_2 = 0x0303, ProtocolVersion::tls_1_3 = 0x0304,
  ProtocolVersion::tls_1_3_20 = 0x7f14, ProtocolVersion::tls_1_3_20_fb = 0xfb14, ProtocolVersion::tls_1_3_21 = 0x7f15, ProtocolVersion::tls_1_3_21_fb = 0xfb15,
  ProtocolVersion::tls_1_3_22 = 0x7f16, ProtocolVersion::tls_1_3_22_fb = 0xfb16, ProtocolVersion::tls_1_3_23 = 0x7f17, ProtocolVersion::tls_1_3_23_fb = 0xfb17,
  ProtocolVersion::tls_1_3_26 = 0x7f1a, ProtocolVersion::tls_1_3_26_fb = 0xfb1a, ProtocolVersion::tls_1_3_28 = 0x7f1c
}
 
enum  ContentType : uint8_t { ContentType::alert = 21, ContentType::handshake = 22, ContentType::application_data = 23, ContentType::change_cipher_spec = 20 }
 
enum  HandshakeType : uint8_t {
  HandshakeType::client_hello = 1, HandshakeType::server_hello = 2, HandshakeType::new_session_ticket = 4, HandshakeType::end_of_early_data = 5,
  HandshakeType::hello_retry_request = 6, HandshakeType::encrypted_extensions = 8, HandshakeType::certificate = 11, HandshakeType::certificate_request = 13,
  HandshakeType::certificate_verify = 15, HandshakeType::finished = 20, HandshakeType::key_update = 24, HandshakeType::compressed_certificate = 240,
  HandshakeType::message_hash = 254
}
 
enum  ExtensionType : uint16_t {
  ExtensionType::server_name = 0, ExtensionType::supported_groups = 10, ExtensionType::signature_algorithms = 13, ExtensionType::application_layer_protocol_negotiation = 16,
  ExtensionType::token_binding = 24, ExtensionType::quic_transport_parameters = 26, ExtensionType::key_share_old = 40, ExtensionType::pre_shared_key = 41,
  ExtensionType::early_data = 42, ExtensionType::supported_versions = 43, ExtensionType::cookie = 44, ExtensionType::psk_key_exchange_modes = 45,
  ExtensionType::certificate_authorities = 47, ExtensionType::post_handshake_auth = 49, ExtensionType::signature_algorithms_cert = 50, ExtensionType::key_share = 51,
  ExtensionType::compress_certificate = 0xff02
}
 
enum  AlertDescription : uint8_t {
  AlertDescription::close_notify = 0, AlertDescription::end_of_early_data = 1, AlertDescription::unexpected_message = 10, AlertDescription::bad_record_mac = 20,
  AlertDescription::record_overflow = 22, AlertDescription::handshake_failure = 40, AlertDescription::bad_certificate = 42, AlertDescription::unsupported_certificate = 43,
  AlertDescription::certificate_revoked = 44, AlertDescription::certificate_expired = 45, AlertDescription::certificate_unknown = 46, AlertDescription::illegal_parameter = 47,
  AlertDescription::unknown_ca = 48, AlertDescription::access_denied = 49, AlertDescription::decode_error = 50, AlertDescription::decrypt_error = 51,
  AlertDescription::protocol_version = 70, AlertDescription::insufficient_security = 71, AlertDescription::internal_error = 80, AlertDescription::inappropriate_fallback = 86,
  AlertDescription::user_canceled = 90, AlertDescription::missing_extension = 109, AlertDescription::unsupported_extension = 110, AlertDescription::certificate_unobtainable = 111,
  AlertDescription::unrecognized_name = 112, AlertDescription::bad_certificate_status_response = 113, AlertDescription::bad_certificate_hash_value = 114, AlertDescription::unknown_psk_identity = 115,
  AlertDescription::certificate_required = 116
}
 
enum  CipherSuite : uint16_t { CipherSuite::TLS_AES_128_GCM_SHA256 = 0x1301, CipherSuite::TLS_AES_256_GCM_SHA384 = 0x1302, CipherSuite::TLS_CHACHA20_POLY1305_SHA256 = 0x1303, CipherSuite::TLS_AES_128_OCB_SHA256_EXPERIMENTAL = 0xFF01 }
 
enum  PskKeyExchangeMode : uint8_t { PskKeyExchangeMode::psk_ke = 0, PskKeyExchangeMode::psk_dhe_ke = 1 }
 
enum  CertificateCompressionAlgorithm : uint16_t { CertificateCompressionAlgorithm::zlib = 1 }
 
enum  SignatureScheme : uint16_t {
  SignatureScheme::ecdsa_secp256r1_sha256 = 0x0403, SignatureScheme::ecdsa_secp384r1_sha384 = 0x0503, SignatureScheme::ecdsa_secp521r1_sha512 = 0x0603, SignatureScheme::rsa_pss_sha256 = 0x0804,
  SignatureScheme::rsa_pss_sha384 = 0x0805, SignatureScheme::rsa_pss_sha512 = 0x0806, SignatureScheme::ed25519 = 0x0807, SignatureScheme::ed448 = 0x0808
}
 
enum  KeyUpdateRequest : uint8_t { KeyUpdateRequest::update_not_requested = 0, KeyUpdateRequest::update_requested = 1 }
 
enum  NamedGroup : uint16_t { NamedGroup::secp256r1 = 23, NamedGroup::secp384r1 = 24, NamedGroup::secp521r1 = 25, NamedGroup::x25519 = 29 }
 

Functions

folly::StringPiece toString (StateEnum state)
 
folly::StringPiece toString (ClientAuthType auth)
 
folly::StringPiece toString (client::StateEnum)
 
folly::StringPiece toString (client::ClientAuthType)
 
void trimBytes (IOBuf &buf, folly::MutableByteRange trimmed)
 
void XOR (ByteRange first, MutableByteRange second)
 
template<typename Func >
void transformBuffer (const folly::IOBuf &in, folly::IOBuf &out, Func func)
 
template<size_t BlockSize, typename Func >
folly::io::RWPrivateCursor transformBufferBlocks (const folly::IOBuf &in, folly::IOBuf &out, Func func)
 
template<>
folly::Optional< TokenBindingParametersgetExtension (const std::vector< Extension > &extensions)
 
template<>
Extension encodeExtension (const TokenBindingParameters &params)
 
template<>
Buf encode (TokenBindingMessage &&message)
 
template<>
TokenBindingMessage decode (folly::io::Cursor &cursor)
 
template<>
folly::Optional< extensions::TokenBindingParametersgetExtension (const std::vector< Extension > &extensions)
 
template<>
extensions::TokenBindingMessage decode (folly::io::Cursor &cursor)
 
template<>
std::vector< SignatureSchemeCertUtils::getSigSchemes< KeyType::P256 > ()
 
template<>
std::vector< SignatureSchemeCertUtils::getSigSchemes< KeyType::P384 > ()
 
template<>
std::vector< SignatureSchemeCertUtils::getSigSchemes< KeyType::P521 > ()
 
template<>
std::vector< SignatureSchemeCertUtils::getSigSchemes< KeyType::RSA > ()
 
folly::StringPiece toString (Event event)
 
HashFunction getHashFunction (CipherSuite cipher)
 
size_t getHashSize (HashFunction hash)
 
folly::StringPiece toString (HashFunction hash)
 
folly::StringPiece toString (PskType pskType)
 
folly::StringPiece toString (KeyExchangeType kexType)
 
folly::StringPiece toString (EarlyDataType earlyDataType)
 
std::vector< Extension >::const_iterator findExtension (const std::vector< Extension > &extensions, ExtensionType type)
 
template<class T >
folly::Optional< TgetExtension (const std::vector< Extension > &extensions)
 
template<>
SignatureAlgorithms getExtension (folly::io::Cursor &cs)
 
template<>
SupportedGroups getExtension (folly::io::Cursor &cs)
 
template<>
folly::Optional< ClientKeySharegetExtension (const std::vector< Extension > &extensions)
 
template<>
ServerKeyShare getExtension (folly::io::Cursor &cs)
 
template<>
HelloRetryRequestKeyShare getExtension (folly::io::Cursor &cs)
 
template<>
ClientPresharedKey getExtension (folly::io::Cursor &cs)
 
template<>
ServerPresharedKey getExtension (folly::io::Cursor &cs)
 
template<>
ClientEarlyData getExtension (folly::io::Cursor &)
 
template<>
ServerEarlyData getExtension (folly::io::Cursor &)
 
template<>
TicketEarlyData getExtension (folly::io::Cursor &cs)
 
template<>
Cookie getExtension (folly::io::Cursor &cs)
 
template<>
SupportedVersions getExtension (folly::io::Cursor &cs)
 
template<>
ServerSupportedVersions getExtension (folly::io::Cursor &cs)
 
template<>
PskKeyExchangeModes getExtension (folly::io::Cursor &cs)
 
template<>
ProtocolNameList getExtension (folly::io::Cursor &cs)
 
template<>
ServerNameList getExtension (folly::io::Cursor &cs)
 
template<>
CertificateAuthorities getExtension (folly::io::Cursor &cs)
 
template<>
CertificateCompressionAlgorithms getExtension (folly::io::Cursor &cs)
 
template<>
Extension encodeExtension (const SignatureAlgorithms &sig)
 
template<>
Extension encodeExtension (const SupportedGroups &groups)
 
template<>
Extension encodeExtension (const ClientKeyShare &share)
 
template<>
Extension encodeExtension (const ServerKeyShare &share)
 
template<>
Extension encodeExtension (const HelloRetryRequestKeyShare &share)
 
template<>
Extension encodeExtension (const ClientPresharedKey &share)
 
template<>
Extension encodeExtension (const ServerPresharedKey &share)
 
template<>
Extension encodeExtension (const ClientEarlyData &)
 
template<>
Extension encodeExtension (const ServerEarlyData &)
 
template<>
Extension encodeExtension (const TicketEarlyData &early)
 
template<>
Extension encodeExtension (const Cookie &cookie)
 
template<>
Extension encodeExtension (const SupportedVersions &versions)
 
template<>
Extension encodeExtension (const ServerSupportedVersions &versions)
 
template<>
Extension encodeExtension (const PskKeyExchangeModes &modes)
 
template<>
Extension encodeExtension (const ProtocolNameList &names)
 
template<>
Extension encodeExtension (const ServerNameList &names)
 
template<>
Extension encodeExtension (const CertificateAuthorities &authorities)
 
template<>
Extension encodeExtension (const CertificateCompressionAlgorithms &cca)
 
size_t getBinderLength (const ClientHello &chlo)
 
template<class T >
T getExtension (folly::io::Cursor &cursor)
 
template<class T >
Extension encodeExtension (const T &t)
 
template<typename T >
static Param parse (Buf handshakeMsg, Buf original)
 
template<>
Param parse< ServerHello > (Buf handshakeMsg, Buf original)
 
template<typename T >
void setWriteDefaults (T *obj)
 
template<>
Buf encode< ServerHello > (ServerHello &&shlo)
 
template<>
Buf encode< HelloRetryRequest > (HelloRetryRequest &&shlo)
 
template<>
Buf encode< EndOfEarlyData > (EndOfEarlyData &&)
 
template<>
Buf encode< EncryptedExtensions > (EncryptedExtensions &&extensions)
 
template<>
Buf encode< CertificateRequest > (CertificateRequest &&cr)
 
template<>
Buf encode< const CertificateMsg & > (const CertificateMsg &cert)
 
template<>
Buf encode< CertificateMsg & > (CertificateMsg &cert)
 
template<>
Buf encode< CertificateMsg > (CertificateMsg &&cert)
 
template<>
Buf encode< CompressedCertificate & > (CompressedCertificate &cc)
 
template<>
Buf encode< CompressedCertificate > (CompressedCertificate &&cc)
 
template<>
Buf encode< CertificateVerify > (CertificateVerify &&certVerify)
 
template<>
Buf encode< Alert > (Alert &&alert)
 
template<>
Buf encode< const ClientHello & > (const ClientHello &chlo)
 
template<>
Buf encode< ClientHello & > (ClientHello &chlo)
 
template<>
Buf encode< ClientHello > (ClientHello &&chlo)
 
template<>
Buf encode< Finished > (Finished &&fin)
 
template<>
Buf encode< NewSessionTicket > (NewSessionTicket &&nst)
 
Buf encodeHkdfLabel (HkdfLabel &&label, const std::string &hkdfLabelPrefix)
 
template<>
Buf encode< KeyUpdate > (KeyUpdate &&keyUpdate)
 
template<>
Buf encode< message_hash > (message_hash &&hash)
 
template<class T >
Buf encodeHandshake (T &&handshakeMsg)
 
template<>
ClientHello decode (folly::io::Cursor &cursor)
 
template<>
ServerHello decode (folly::io::Cursor &cursor)
 
template<>
EndOfEarlyData decode (folly::io::Cursor &)
 
template<>
EncryptedExtensions decode (folly::io::Cursor &cursor)
 
template<>
CertificateRequest decode (folly::io::Cursor &cursor)
 
template<>
CertificateMsg decode (folly::io::Cursor &cursor)
 
template<>
CompressedCertificate decode (folly::io::Cursor &cursor)
 
template<>
CertificateVerify decode (folly::io::Cursor &cursor)
 
template<>
NewSessionTicket decode< NewSessionTicket > (folly::io::Cursor &cursor)
 
template<>
Alert decode (folly::io::Cursor &cursor)
 
template<>
Finished decode< Finished > (std::unique_ptr< folly::IOBuf > &&buf)
 
template<>
KeyUpdate decode< KeyUpdate > (folly::io::Cursor &cursor)
 
template<class T >
T decode (std::unique_ptr< folly::IOBuf > &&buf)
 
template<typename T >
std::string enumToHex (T enumValue)
 
ProtocolVersion getRealDraftVersion (ProtocolVersion version)
 
std::string toString (ProtocolVersion version)
 
std::string toString (ExtensionType extType)
 
std::string toString (AlertDescription alertDesc)
 
std::string toString (CipherSuite cipher)
 
std::string toString (PskKeyExchangeMode pskKeMode)
 
std::string toString (SignatureScheme sigScheme)
 
std::string toString (NamedGroup group)
 
std::string toString (CertificateCompressionAlgorithm algo)
 
template<class T >
Buf encode (T &&t)
 
template<class T >
T decode (folly::io::Cursor &cursor)
 
folly::StringPiece toString (ReplayCacheResult result)
 
folly::StringPiece toString (server::ReplayCacheResult)
 
folly::StringPiece toString (server::StateEnum state)
 
std::string toString (fizz::server::CertificateStorage storage)
 
static int passwordCallback (char *password, int size, int, void *data)
 
template<>
CipherSuite parse (folly::StringPiece s)
 
template<>
NamedGroup parse (folly::StringPiece s)
 
template<class T >
T parse (folly::StringPiece s)
 

Variables

static const uint32_t kMinReadSize = 1460
 
static const uint32_t kMaxReadSize = 4000
 
static const uint32_t kMaxBufSize = 64 * 1024
 
static constexpr uint16_t kMaxEncryptedRecordSize = 0x4000 + 256
 
static constexpr size_t kEncryptedHeaderSize
 
constexpr uint16_t kMaxPlaintextRecordSize = 0x4000
 
constexpr uint16_t kMinSuggestedRecordSize = 1500
 
static constexpr size_t kPlaintextHeaderSize
 
static constexpr size_t kHandshakeHeaderSize
 
constexpr folly::StringPiece kHkdfLabelPrefix = "tls13 "
 
constexpr folly::StringPiece FakeChangeCipherSpec
 
constexpr size_t kMaxHandshakeSize = 0x20000
 

Typedef Documentation

using fizz::Buf = typedef std::unique_ptr<folly::IOBuf>

Definition at line 22 of file Types.h.

typedef typename std::underlying_type< ContentType >::type fizz::ContentTypeType

Definition at line 13 of file EncryptedRecordLayer.cpp.

using fizz::HandshakeTypeType = typedef typename std::underlying_type<HandshakeType>::type

Definition at line 13 of file RecordLayer.cpp.

Definition at line 17 of file ECCurveKeyExchange.h.

Definition at line 21 of file ECCurveKeyExchange.h.

Definition at line 25 of file ECCurveKeyExchange.h.

typedef typename std::underlying_type< ProtocolVersion >::type fizz::ProtocolVersionType

Definition at line 15 of file EncryptedRecordLayer.cpp.

using fizz::Random = typedef std::array<uint8_t, 32>

Definition at line 184 of file Types.h.

Enumeration Type Documentation

Enumerator
close_notify 
end_of_early_data 
unexpected_message 
bad_record_mac 
record_overflow 
handshake_failure 
bad_certificate 
unsupported_certificate 
certificate_revoked 
certificate_expired 
certificate_unknown 
illegal_parameter 
unknown_ca 
access_denied 
decode_error 
decrypt_error 
protocol_version 
insufficient_security 
internal_error 
inappropriate_fallback 
user_canceled 
missing_extension 
unsupported_extension 
certificate_unobtainable 
unrecognized_name 
bad_certificate_status_response 
bad_certificate_hash_value 
unknown_psk_identity 
certificate_required 

Definition at line 119 of file Types.h.

119  : uint8_t {
120  close_notify = 0,
121  end_of_early_data = 1,
122  unexpected_message = 10,
123  bad_record_mac = 20,
124  record_overflow = 22,
125  handshake_failure = 40,
126  bad_certificate = 42,
128  certificate_revoked = 44,
129  certificate_expired = 45,
130  certificate_unknown = 46,
131  illegal_parameter = 47,
132  unknown_ca = 48,
133  access_denied = 49,
134  decode_error = 50,
135  decrypt_error = 51,
136  protocol_version = 70,
138  internal_error = 80,
140  user_canceled = 90,
141  missing_extension = 109,
142  unsupported_extension = 110,
144  unrecognized_name = 112,
147  unknown_psk_identity = 115,
149 };
Enumerator
ClientAppTraffic 
ServerAppTraffic 

Definition at line 28 of file KeyScheduler.h.

Enumerator
zlib 

Definition at line 167 of file Types.h.

enum fizz::CipherSuite : uint16_t
strong
Enumerator
TLS_AES_128_GCM_SHA256 
TLS_AES_256_GCM_SHA384 
TLS_CHACHA20_POLY1305_SHA256 
TLS_AES_128_OCB_SHA256_EXPERIMENTAL 

Definition at line 153 of file Types.h.

enum fizz::ContentType : uint8_t
strong
Enumerator
alert 
handshake 
application_data 
change_cipher_spec 

Definition at line 46 of file Types.h.

enum fizz::Direction : uint8_t
strong
Enumerator
UPSTREAM 
DOWNSTREAM 

Definition at line 21 of file ExportedAuthenticator.h.

21  : uint8_t {
22  UPSTREAM, // toward the server
23  DOWNSTREAM // toward the client
24 };
enum fizz::EarlyDataType
strong
Enumerator
NotAttempted 
Attempted 
Rejected 
Accepted 

Definition at line 33 of file Types.h.

enum fizz::EarlySecrets
strong
Enumerator
ExternalPskBinder 
ResumptionPskBinder 
ClientEarlyTraffic 
EarlyExporter 

Definition at line 17 of file KeyScheduler.h.

enum fizz::EncryptionLevel
strong

Encryption level for the TLS layer.

Enumerator
Plaintext 
Handshake 
EarlyData 
AppTraffic 

Definition at line 29 of file Types.h.

enum fizz::Event
strong
Enumerator
ClientHello 
ServerHello 
EndOfEarlyData 
HelloRetryRequest 
EncryptedExtensions 
CertificateRequest 
Certificate 
CompressedCertificate 
CertificateVerify 
Finished 
NewSessionTicket 
KeyUpdate 
Alert 
Accept 
Connect 
AppData 
EarlyAppWrite 
AppWrite 
AppClose 
WriteNewSessionTicket 
NUM_EVENTS 

Definition at line 15 of file Events.h.

Enumerator
server_name 
supported_groups 
signature_algorithms 
application_layer_protocol_negotiation 
token_binding 
quic_transport_parameters 
key_share_old 
pre_shared_key 
early_data 
supported_versions 
cookie 
psk_key_exchange_modes 
certificate_authorities 
post_handshake_auth 
signature_algorithms_cert 
key_share 
compress_certificate 

Definition at line 95 of file Types.h.

Enumerator
ClientHandshakeTraffic 
ServerHandshakeTraffic 

Definition at line 24 of file KeyScheduler.h.

enum fizz::HashFunction
strong
Enumerator
Sha256 
Sha384 

Definition at line 16 of file Types.h.

enum fizz::KeyExchangeType
strong
Enumerator
None 
OneRtt 
HelloRetryRequest 

Definition at line 31 of file Types.h.

enum fizz::KeyType
strong
Enumerator
RSA 
P256 
P384 
P521 

Definition at line 17 of file Signature.h.

Enumerator
update_not_requested 
update_requested 

Definition at line 292 of file Types.h.

enum fizz::MasterSecrets
strong
Enumerator
ExporterMaster 
ResumptionMaster 

Definition at line 26 of file KeyScheduler.h.

enum fizz::NamedGroup : uint16_t
strong
Enumerator
secp256r1 
secp384r1 
secp521r1 
x25519 

Definition at line 302 of file Types.h.

Enumerator
tls_1_0 
tls_1_1 
tls_1_2 
tls_1_3 
tls_1_3_20 
tls_1_3_20_fb 
tls_1_3_21 
tls_1_3_21_fb 
tls_1_3_22 
tls_1_3_22_fb 
tls_1_3_23 
tls_1_3_23_fb 
tls_1_3_26 
tls_1_3_26_fb 
tls_1_3_28 

Definition at line 24 of file Types.h.

Enumerator
psk_ke 
psk_dhe_ke 

Definition at line 163 of file Types.h.

enum fizz::PskType
strong
Enumerator
NotSupported 
NotAttempted 
Rejected 
External 
Resumption 

Definition at line 18 of file Types.h.

Enumerator
host_name 

Definition at line 120 of file Extensions.h.

Enumerator
ecdsa_secp256r1_sha256 
ecdsa_secp384r1_sha384 
ecdsa_secp521r1_sha512 
rsa_pss_sha256 
rsa_pss_sha384 
rsa_pss_sha512 
ed25519 
ed448 

Definition at line 257 of file Types.h.

Which context we are verifying in (ie client context means we are a client verifying server certificates).

Enumerator
Client 
Server 
Client 
Server 

Definition at line 19 of file DefaultCertificateVerifier.h.

Which context we are verifying in (ie client context means we are a client verifying server certificates).

Enumerator
Client 
Server 
Client 
Server 

Definition at line 19 of file JavaCryptoCertificateVerifier.h.

Function Documentation

template<>
std::vector<SignatureScheme> fizz::CertUtils::getSigSchemes< KeyType::P256 > ( )
inline

Definition at line 17 of file Certificate-inl.h.

References ecdsa_secp256r1_sha256.

17  {
18  return {SignatureScheme::ecdsa_secp256r1_sha256};
19 }
template<>
std::vector<SignatureScheme> fizz::CertUtils::getSigSchemes< KeyType::P384 > ( )
inline

Definition at line 22 of file Certificate-inl.h.

References ecdsa_secp384r1_sha384.

22  {
23  return {SignatureScheme::ecdsa_secp384r1_sha384};
24 }
template<>
std::vector<SignatureScheme> fizz::CertUtils::getSigSchemes< KeyType::P521 > ( )
inline

Definition at line 27 of file Certificate-inl.h.

References ecdsa_secp521r1_sha512.

27  {
28  return {SignatureScheme::ecdsa_secp521r1_sha512};
29 }
template<>
std::vector<SignatureScheme> fizz::CertUtils::getSigSchemes< KeyType::RSA > ( )
inline

Definition at line 32 of file Certificate-inl.h.

References rsa_pss_sha256.

32  {
33  return {SignatureScheme::rsa_pss_sha256};
34 }
template<>
extensions::TokenBindingMessage fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 132 of file Types.cpp.

132  {
134  detail::readVector<uint16_t>(message.tokenbindings, cursor);
135  return message;
136 }
std::vector< TokenBinding > tokenbindings
Definition: Types.h:66
std::string message
Definition: SPDYCodec.cpp:133
template<class T >
T fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 132 of file Types.cpp.

References alert, fizz::CompressedCertificate::algorithm, fizz::CertificateVerify::algorithm, cc, fizz::CertificateMsg::certificate_list, fizz::CertificateMsg::certificate_request_context, fizz::CertificateRequest::certificate_request_context, chlo, fizz::ServerHello::cipher_suite, fizz::ClientHello::cipher_suites, fizz::CompressedCertificate::compressed_certificate_message, fizz::Alert::description, fizz::ClientHello::extensions, fizz::ServerHello::extensions, fizz::EncryptedExtensions::extensions, fizz::CertificateRequest::extensions, folly::io::detail::CursorBase< Derived, BufType >::isAtEnd(), fizz::ServerHello::legacy_compression_method, fizz::ClientHello::legacy_compression_methods, fizz::ClientHello::legacy_session_id, fizz::ServerHello::legacy_session_id_echo, fizz::ClientHello::legacy_version, fizz::ServerHello::legacy_version, fizz::Alert::level, message, fizz::ClientHello::random, fizz::ServerHello::random, fizz::detail::read(), fizz::detail::readBits24(), fizz::CertificateVerify::signature, fizz::extensions::TokenBindingMessage::tokenbindings, and fizz::CompressedCertificate::uncompressed_length.

Referenced by folly::AtomicStruct< folly::IndexedMemPool::TaggedPtr, Atom >::compare_exchange_strong(), folly::AtomicStruct< folly::IndexedMemPool::TaggedPtr, Atom >::compare_exchange_weak(), proxygen::compress::CompressionSimulator::decodePacket(), fizz::server::AeadTicketCipher< AeadType, CodecType, HkdfType >::decrypt(), folly::AtomicStruct< folly::IndexedMemPool::TaggedPtr, Atom >::exchange(), isLowercase(), folly::AtomicStruct< folly::IndexedMemPool::TaggedPtr, Atom >::load(), folly::AtomicStruct< T, Atom >::operator T(), folly::AtomicStruct< folly::IndexedMemPool::TaggedPtr, Atom >::operator=(), TEST(), fizz::server::test::TEST(), TEST_F(), fizz::test::TYPED_TEST(), folly::json_pointer::unescape(), proxygen::Base64::urlDecode(), and proxygen::huffman::HuffTree::~HuffTree().

132  {
134  detail::readVector<uint16_t>(message.tokenbindings, cursor);
135  return message;
136 }
std::vector< TokenBinding > tokenbindings
Definition: Types.h:66
std::string message
Definition: SPDYCodec.cpp:133
template<>
ClientHello fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 527 of file Types-inl.h.

References chlo, fizz::ClientHello::cipher_suites, fizz::ClientHello::extensions, folly::io::detail::CursorBase< Derived, BufType >::isAtEnd(), fizz::ClientHello::legacy_compression_methods, fizz::ClientHello::legacy_session_id, fizz::ClientHello::legacy_version, fizz::ClientHello::random, and fizz::detail::read().

527  {
529  detail::read(chlo.legacy_version, cursor);
530  detail::read(chlo.random, cursor);
531  detail::readBuf<uint8_t>(chlo.legacy_session_id, cursor);
532  detail::readVector<uint16_t>(chlo.cipher_suites, cursor);
533  detail::readVector<uint8_t>(chlo.legacy_compression_methods, cursor);
534  // Before TLS 1.3 clients could omit the extensions section entirely. If we're
535  // already at the end of the client hello we won't try and read extensions so
536  // that this isn't treated as a parse error.
537  if (!cursor.isAtEnd()) {
538  detail::readVector<uint16_t>(chlo.extensions, cursor);
539  }
540  return chlo;
541 }
static const std::string chlo
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
ServerHello fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 544 of file Types-inl.h.

References fizz::ServerHello::cipher_suite, fizz::ServerHello::extensions, fizz::ServerHello::legacy_compression_method, fizz::ServerHello::legacy_session_id_echo, fizz::ServerHello::legacy_version, fizz::ServerHello::random, and fizz::detail::read().

544  {
545  ServerHello shlo;
546  detail::read(shlo.legacy_version, cursor);
547  detail::read(shlo.random, cursor);
548  detail::readBuf<uint8_t>(shlo.legacy_session_id_echo, cursor);
549  detail::read(shlo.cipher_suite, cursor);
550  detail::read(shlo.legacy_compression_method, cursor);
551  detail::readVector<uint16_t>(shlo.extensions, cursor);
552  return shlo;
553 }
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
EndOfEarlyData fizz::decode ( folly::io::Cursor )
inline

Definition at line 556 of file Types-inl.h.

556  {
557  return EndOfEarlyData();
558 }
template<>
EncryptedExtensions fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 561 of file Types-inl.h.

References fizz::EncryptedExtensions::extensions.

561  {
563  detail::readVector<uint16_t>(ee.extensions, cursor);
564  return ee;
565 }
template<>
CertificateRequest fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 568 of file Types-inl.h.

References fizz::CertificateRequest::certificate_request_context, and fizz::CertificateRequest::extensions.

568  {
570  detail::readBuf<uint8_t>(cr.certificate_request_context, cursor);
571  detail::readVector<uint16_t>(cr.extensions, cursor);
572  return cr;
573 }
template<>
CertificateMsg fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 576 of file Types-inl.h.

References fizz::CertificateMsg::certificate_list, and fizz::CertificateMsg::certificate_request_context.

576  {
577  CertificateMsg cert;
578  detail::readBuf<uint8_t>(cert.certificate_request_context, cursor);
579  detail::readVector<detail::bits24>(cert.certificate_list, cursor);
580  return cert;
581 }
template<>
CompressedCertificate fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 584 of file Types-inl.h.

References fizz::CompressedCertificate::algorithm, cc, fizz::CompressedCertificate::compressed_certificate_message, fizz::detail::read(), fizz::detail::readBits24(), and fizz::CompressedCertificate::uncompressed_length.

584  {
586  detail::read(cc.algorithm, cursor);
587  cc.uncompressed_length = detail::readBits24(cursor);
588  detail::readBuf<detail::bits24>(cc.compressed_certificate_message, cursor);
589  return cc;
590 }
The non test part of the code is expected to have failures gtest_output_test_ cc
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
uint32_t readBits24(folly::io::Cursor &cursor)
Definition: Types-inl.h:210
template<>
CertificateVerify fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 593 of file Types-inl.h.

References fizz::CertificateVerify::algorithm, fizz::detail::read(), and fizz::CertificateVerify::signature.

593  {
594  CertificateVerify certVerify;
595  detail::read(certVerify.algorithm, cursor);
596  detail::readBuf<uint16_t>(certVerify.signature, cursor);
597  return certVerify;
598 }
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
Alert fizz::decode ( folly::io::Cursor cursor)
inline

Definition at line 612 of file Types-inl.h.

References alert, fizz::Alert::description, fizz::Alert::level, message, fizz::detail::read(), and fizz::extensions::TokenBindingMessage::tokenbindings.

612  {
613  Alert alert;
614  detail::read(alert.level, cursor);
615  detail::read(alert.description, cursor);
616  return alert;
617 }
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<class T >
T fizz::decode ( std::unique_ptr< folly::IOBuf > &&  buf)

Definition at line 634 of file Types-inl.h.

634  {
635  folly::io::Cursor cursor(buf.get());
636  auto decoded = decode<T>(cursor);
637 
638  if (!cursor.isAtEnd()) {
639  throw std::runtime_error("didn't read entire message");
640  }
641 
642  return decoded;
643 }
template<>
Finished fizz::decode< Finished > ( std::unique_ptr< folly::IOBuf > &&  buf)
inline

Definition at line 620 of file Types-inl.h.

References folly::gen::move, and fizz::Finished::verify_data.

620  {
621  Finished fin;
622  fin.verify_data = std::move(buf);
623  return fin;
624 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<>
KeyUpdate fizz::decode< KeyUpdate > ( folly::io::Cursor cursor)
inline

Definition at line 627 of file Types-inl.h.

References fizz::detail::read(), and fizz::KeyUpdate::request_update.

627  {
628  KeyUpdate update;
629  detail::read(update.request_update, cursor);
630  return update;
631 }
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258

Definition at line 601 of file Types-inl.h.

References fizz::NewSessionTicket::extensions, nst, fizz::detail::read(), fizz::NewSessionTicket::ticket, fizz::NewSessionTicket::ticket_age_add, fizz::NewSessionTicket::ticket_lifetime, and fizz::NewSessionTicket::ticket_nonce.

601  {
603  detail::read(nst.ticket_lifetime, cursor);
604  detail::read(nst.ticket_age_add, cursor);
605  detail::readBuf<uint8_t>(nst.ticket_nonce, cursor);
606  detail::readBuf<uint16_t>(nst.ticket, cursor);
607  detail::readVector<uint16_t>(nst.extensions, cursor);
608  return nst;
609 }
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
static const std::string nst
template<>
Buf fizz::encode ( TokenBindingMessage &&  message)

Definition at line 124 of file Types.cpp.

References folly::IOBuf::create().

Referenced by fizz::ZlibCertificateCompressor::compress(), encodeHandshake(), fizz::test::ProtocolTest< ClientTypes, Actions >::expectError(), fizz::test::TEST_F(), fizz::server::test::TEST_F(), and fizz::WriteRecordLayer::writeAlert().

124  {
125  auto buf = folly::IOBuf::create(20);
126  folly::io::Appender appender(buf.get(), 20);
127  detail::writeVector<uint16_t>(message.tokenbindings, appender);
128  return buf;
129 }
Definition: test.c:42
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<class T >
Buf fizz::encode ( T &&  t)
template<>
Buf fizz::encode< Alert > ( Alert &&  alert)
inline

Definition at line 436 of file Types-inl.h.

References alert, folly::IOBuf::create(), and fizz::detail::write().

436  {
437  auto buf = folly::IOBuf::create(2);
438  folly::io::Appender appender(buf.get(), 2);
439  detail::write(alert.level, appender);
440  detail::write(alert.description, appender);
441  return buf;
442 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Buf fizz::encode< CertificateMsg & > ( CertificateMsg cert)
inline

Definition at line 402 of file Types-inl.h.

References encode< const CertificateMsg & >().

Referenced by encode< CertificateMsg >().

402  {
403  return encode<const CertificateMsg&>(cert);
404 }
Buf encode< const CertificateMsg & >(const CertificateMsg &cert)
Definition: Types-inl.h:393
template<>
Buf fizz::encode< CertificateMsg > ( CertificateMsg &&  cert)
inline

Definition at line 407 of file Types-inl.h.

References encode< CertificateMsg & >().

407  {
408  return encode<CertificateMsg&>(cert);
409 }
Buf encode< CertificateMsg & >(CertificateMsg &cert)
Definition: Types-inl.h:402
template<>
Buf fizz::encode< CertificateRequest > ( CertificateRequest &&  cr)
inline

Definition at line 384 of file Types-inl.h.

References folly::IOBuf::create().

Referenced by fizz::ExportedAuthenticator::getAuthenticatorRequest(), and fizz::test::AuthenticatorTest::SetUp().

384  {
385  auto buf = folly::IOBuf::create(20);
386  folly::io::Appender appender(buf.get(), 20);
387  detail::writeBuf<uint8_t>(cr.certificate_request_context, appender);
388  detail::writeVector<uint16_t>(cr.extensions, appender);
389  return buf;
390 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Buf fizz::encode< CertificateVerify > ( CertificateVerify &&  certVerify)
inline

Definition at line 427 of file Types-inl.h.

References folly::IOBuf::create(), and fizz::detail::write().

427  {
428  auto buf = folly::IOBuf::create(20);
429  folly::io::Appender appender(buf.get(), 20);
430  detail::write(certVerify.algorithm, appender);
431  detail::writeBuf<uint16_t>(certVerify.signature, appender);
432  return buf;
433 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Buf fizz::encode< ClientHello & > ( ClientHello chlo)
inline

Definition at line 460 of file Types-inl.h.

References chlo, and encode< const ClientHello & >().

Referenced by encode< ClientHello >().

460  {
462 }
Buf encode< const ClientHello & >(const ClientHello &chlo)
Definition: Types-inl.h:445
static const std::string chlo
template<>
Buf fizz::encode< ClientHello > ( ClientHello &&  chlo)
inline

Definition at line 465 of file Types-inl.h.

References chlo, and encode< ClientHello & >().

465  {
466  return encode<ClientHello&>(chlo);
467 }
static const std::string chlo
Buf encode< ClientHello & >(ClientHello &chlo)
Definition: Types-inl.h:460
template<>
Buf fizz::encode< CompressedCertificate & > ( CompressedCertificate cc)
inline

Definition at line 412 of file Types-inl.h.

References cc, folly::IOBuf::create(), fizz::detail::write(), and fizz::detail::writeBits24().

Referenced by encode< CompressedCertificate >().

412  {
413  auto buf = folly::IOBuf::create(20);
414  folly::io::Appender appender(buf.get(), 20);
415  detail::write(cc.algorithm, appender);
416  detail::writeBits24(cc.uncompressed_length, appender);
417  detail::writeBuf<detail::bits24>(cc.compressed_certificate_message, appender);
418  return buf;
419 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
The non test part of the code is expected to have failures gtest_output_test_ cc
void writeBits24(T len, folly::io::Appender &out)
Definition: Types-inl.h:102

Definition at line 422 of file Types-inl.h.

References cc, and encode< CompressedCertificate & >().

422  {
424 }
The non test part of the code is expected to have failures gtest_output_test_ cc
Buf encode< CompressedCertificate & >(CompressedCertificate &cc)
Definition: Types-inl.h:412
template<>
Buf fizz::encode< const CertificateMsg & > ( const CertificateMsg cert)
inline

Definition at line 393 of file Types-inl.h.

References folly::IOBuf::create().

Referenced by encode< CertificateMsg & >().

393  {
394  auto buf = folly::IOBuf::create(20);
395  folly::io::Appender appender(buf.get(), 20);
396  detail::writeBuf<uint8_t>(cert.certificate_request_context, appender);
397  detail::writeVector<detail::bits24>(cert.certificate_list, appender);
398  return buf;
399 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Buf fizz::encode< const ClientHello & > ( const ClientHello chlo)
inline

Definition at line 445 of file Types-inl.h.

References chlo, folly::IOBuf::create(), uint8_t, and fizz::detail::write().

Referenced by encode< ClientHello & >().

445  {
446  auto buf = folly::IOBuf::create(
447  sizeof(ProtocolVersion) + sizeof(Random) + sizeof(uint8_t) +
448  sizeof(CipherSuite) * chlo.cipher_suites.size() + sizeof(uint8_t) + 20);
449  folly::io::Appender appender(buf.get(), 20);
450  detail::write(chlo.legacy_version, appender);
451  detail::write(chlo.random, appender);
452  detail::writeBuf<uint8_t>(chlo.legacy_session_id, appender);
453  detail::writeVector<uint16_t>(chlo.cipher_suites, appender);
454  detail::writeVector<uint8_t>(chlo.legacy_compression_methods, appender);
455  detail::writeVector<uint16_t>(chlo.extensions, appender);
456  return buf;
457 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static const std::string chlo
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
CipherSuite
Definition: Types.h:153
ProtocolVersion
Definition: Types.h:24
template<>
Buf fizz::encode< EncryptedExtensions > ( EncryptedExtensions &&  extensions)
inline

Definition at line 376 of file Types-inl.h.

References folly::IOBuf::create().

376  {
377  auto buf = folly::IOBuf::create(20);
378  folly::io::Appender appender(buf.get(), 20);
379  detail::writeVector<uint16_t>(extensions.extensions, appender);
380  return buf;
381 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Buf fizz::encode< EndOfEarlyData > ( EndOfEarlyData &&  )
inline

Definition at line 371 of file Types-inl.h.

References folly::IOBuf::create().

371  {
372  return folly::IOBuf::create(0);
373 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Buf fizz::encode< Finished > ( Finished &&  fin)
inline

Definition at line 470 of file Types-inl.h.

References folly::gen::move.

470  {
471  return std::move(fin.verify_data);
472 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<>
Buf fizz::encode< HelloRetryRequest > ( HelloRetryRequest &&  shlo)
inline

Definition at line 357 of file Types-inl.h.

References folly::IOBuf::create(), fizz::HelloRetryRequest::HrrRandom, and fizz::detail::write().

357  {
358  auto buf = folly::IOBuf::create(
359  sizeof(ProtocolVersion) + sizeof(Random) + sizeof(CipherSuite) + 20);
360  folly::io::Appender appender(buf.get(), 20);
361  detail::write(shlo.legacy_version, appender);
362  detail::write(HelloRetryRequest::HrrRandom, appender);
363  detail::writeBuf<uint8_t>(shlo.legacy_session_id_echo, appender);
364  detail::write(shlo.cipher_suite, appender);
365  detail::write(shlo.legacy_compression_method, appender);
366  detail::writeVector<uint16_t>(shlo.extensions, appender);
367  return buf;
368 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
CipherSuite
Definition: Types.h:153
ProtocolVersion
Definition: Types.h:24
template<>
Buf fizz::encode< KeyUpdate > ( KeyUpdate &&  keyUpdate)
inline

Definition at line 502 of file Types-inl.h.

References folly::IOBuf::create(), and fizz::detail::write().

502  {
503  auto buf = folly::IOBuf::create(20);
504  folly::io::Appender appender(buf.get(), 20);
505  detail::write(keyUpdate.request_update, appender);
506  return buf;
507 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Buf fizz::encode< message_hash > ( message_hash &&  hash)
inline

Definition at line 510 of file Types-inl.h.

References folly::gen::move.

510  {
511  return std::move(hash.hash);
512 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<>
Buf fizz::encode< NewSessionTicket > ( NewSessionTicket &&  nst)
inline

Definition at line 475 of file Types-inl.h.

References folly::IOBuf::create(), nst, and fizz::detail::write().

475  {
476  auto buf = folly::IOBuf::create(20);
477  folly::io::Appender appender(buf.get(), 20);
478  detail::write(nst.ticket_lifetime, appender);
479  detail::write(nst.ticket_age_add, appender);
480  if (nst.ticket_nonce) {
481  detail::writeBuf<uint8_t>(nst.ticket_nonce, appender);
482  }
483  detail::writeBuf<uint16_t>(nst.ticket, appender);
484  detail::writeVector<uint16_t>(nst.extensions, appender);
485  return buf;
486 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
static const std::string nst
template<>
Buf fizz::encode< ServerHello > ( ServerHello &&  shlo)
inline

Definition at line 339 of file Types-inl.h.

References folly::IOBuf::create(), and fizz::detail::write().

339  {
340  auto buf = folly::IOBuf::create(
341  sizeof(ProtocolVersion) + sizeof(Random) + sizeof(CipherSuite) + 20);
342  folly::io::Appender appender(buf.get(), 20);
343  detail::write(shlo.legacy_version, appender);
344  detail::write(shlo.random, appender);
345  if (shlo.legacy_session_id_echo) {
346  detail::writeBuf<uint8_t>(shlo.legacy_session_id_echo, appender);
347  }
348  detail::write(shlo.cipher_suite, appender);
349  if (shlo.legacy_session_id_echo) {
350  detail::write(shlo.legacy_compression_method, appender);
351  }
352  detail::writeVector<uint16_t>(shlo.extensions, appender);
353  return buf;
354 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
CipherSuite
Definition: Types.h:153
ProtocolVersion
Definition: Types.h:24
template<>
Extension fizz::encodeExtension ( const TokenBindingParameters params)

Definition at line 113 of file Types.cpp.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, fizz::extensions::TokenBindingParameters::key_parameters_list, token_binding, fizz::extensions::TokenBindingParameters::version, and fizz::detail::write().

Referenced by fizz::test::TestMessages::addPsk(), fizz::test::TestMessages::certificateRequest(), fizz::test::ExtensionsTest::checkEncode(), fizz::test::TestMessages::clientHello(), fizz::test::TestMessages::clientHelloPskEarly(), fizz::sm::encodeAndAddBinders(), fizz::test::TestMessages::encryptedExt(), fizz::test::TestMessages::encryptedExtEarly(), fizz::sm::getCertificateRequest(), fizz::JavaCryptoCertificateVerifier::getCertificateRequestExtensions(), fizz::DefaultCertificateVerifier::getCertificateRequestExtensions(), fizz::server::test::AeadCookieCipherTest::getClientHello(), fizz::sm::getClientHello(), fizz::extensions::TokenBindingClientExtension::getClientHelloExtensions(), fizz::sm::getEncryptedExt(), fizz::extensions::TokenBindingServerExtension::getExtensions(), fizz::sm::getHelloRetryRequest(), fizz::sm::getServerHello(), fizz::server::getStatelessHelloRetryRequest(), fizz::test::TestMessages::helloRetryRequest(), fizz::test::TestMessages::serverHello(), fizz::test::TestMessages::serverHelloPsk(), fizz::test::AuthenticatorTest::SetUp(), fizz::extensions::test::TokenBindingClientExtensionTest::setUpServerHelloExtensions(), fizz::extensions::test::TokenBindingServerExtensionTest::setUpTokenBindingWithParameters(), TEST(), fizz::test::TEST_F(), fizz::server::test::TEST_F(), fizz::client::test::TEST_F(), TEST_F(), and fizz::sm::writeNewSessionTicket().

113  {
114  Extension ext;
115  ext.extension_type = ExtensionType::token_binding;
116  ext.extension_data = folly::IOBuf::create(0);
117  folly::io::Appender appender(ext.extension_data.get(), 10);
118  detail::write(params.version, appender);
119  detail::writeVector<uint8_t>(params.key_parameters_list, appender);
120  return ext;
121 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
TokenBindingProtocolVersion version
Definition: Types.h:42
std::vector< TokenBindingKeyParameters > key_parameters_list
Definition: Types.h:43
template<class T >
Extension fizz::encodeExtension ( const T t)
template<>
Extension fizz::encodeExtension ( const SignatureAlgorithms sig)
inline

Definition at line 175 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, signature_algorithms, and fizz::SignatureAlgorithms::supported_signature_algorithms.

175  {
176  Extension ext;
177  ext.extension_type = ExtensionType::signature_algorithms;
178  ext.extension_data = folly::IOBuf::create(0);
179  folly::io::Appender appender(ext.extension_data.get(), 10);
180  detail::writeVector<uint16_t>(sig.supported_signature_algorithms, appender);
181  return ext;
182 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
template<>
Extension fizz::encodeExtension ( const SupportedGroups groups)
inline

Definition at line 185 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, fizz::SupportedGroups::named_group_list, and supported_groups.

185  {
186  Extension ext;
187  ext.extension_type = ExtensionType::supported_groups;
188  ext.extension_data = folly::IOBuf::create(0);
189  folly::io::Appender appender(ext.extension_data.get(), 10);
190  detail::writeVector<uint16_t>(groups.named_group_list, appender);
191  return ext;
192 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const ClientKeyShare share)
inline

Definition at line 195 of file Extensions-inl.h.

References fizz::ClientKeyShare::client_shares, folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, key_share, key_share_old, and fizz::ClientKeyShare::preDraft23.

195  {
196  Extension ext;
197  ext.extension_type = share.preDraft23 ? ExtensionType::key_share_old
198  : ExtensionType::key_share;
199  ext.extension_data = folly::IOBuf::create(0);
200  folly::io::Appender appender(ext.extension_data.get(), 10);
201  detail::writeVector<uint16_t>(share.client_shares, appender);
202  return ext;
203 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
template<>
Extension fizz::encodeExtension ( const ServerKeyShare share)
inline

Definition at line 206 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, key_share, key_share_old, fizz::ServerKeyShare::preDraft23, fizz::ServerKeyShare::server_share, and fizz::detail::write().

206  {
207  Extension ext;
208  ext.extension_type = share.preDraft23 ? ExtensionType::key_share_old
209  : ExtensionType::key_share;
210  ext.extension_data = folly::IOBuf::create(0);
211  folly::io::Appender appender(ext.extension_data.get(), 10);
212  detail::write(share.server_share, appender);
213  return ext;
214 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
template<>
Extension fizz::encodeExtension ( const HelloRetryRequestKeyShare share)
inline

Definition at line 217 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, key_share, key_share_old, fizz::HelloRetryRequestKeyShare::preDraft23, fizz::HelloRetryRequestKeyShare::selected_group, and fizz::detail::write().

217  {
218  Extension ext;
219  ext.extension_type = share.preDraft23 ? ExtensionType::key_share_old
220  : ExtensionType::key_share;
221  ext.extension_data = folly::IOBuf::create(0);
222  folly::io::Appender appender(ext.extension_data.get(), 10);
223  detail::write(share.selected_group, appender);
224  return ext;
225 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
template<>
Extension fizz::encodeExtension ( const ClientPresharedKey share)
inline

Definition at line 228 of file Extensions-inl.h.

References fizz::ClientPresharedKey::binders, folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, fizz::ClientPresharedKey::identities, and pre_shared_key.

228  {
229  Extension ext;
230  ext.extension_type = ExtensionType::pre_shared_key;
231  ext.extension_data = folly::IOBuf::create(0);
232  folly::io::Appender appender(ext.extension_data.get(), 10);
233  detail::writeVector<uint16_t>(share.identities, appender);
234  detail::writeVector<uint16_t>(share.binders, appender);
235  return ext;
236 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
template<>
Extension fizz::encodeExtension ( const ServerPresharedKey share)
inline

Definition at line 239 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, pre_shared_key, fizz::ServerPresharedKey::selected_identity, and fizz::detail::write().

239  {
240  Extension ext;
241  ext.extension_type = ExtensionType::pre_shared_key;
242  ext.extension_data = folly::IOBuf::create(0);
243  folly::io::Appender appender(ext.extension_data.get(), 10);
244  detail::write(share.selected_identity, appender);
245  return ext;
246 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
template<>
Extension fizz::encodeExtension ( const ClientEarlyData )
inline

Definition at line 249 of file Extensions-inl.h.

References folly::IOBuf::create(), early_data, fizz::Extension::extension_data, and fizz::Extension::extension_type.

249  {
250  Extension ext;
251  ext.extension_type = ExtensionType::early_data;
252  ext.extension_data = folly::IOBuf::create(0);
253  return ext;
254 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const ServerEarlyData )
inline

Definition at line 257 of file Extensions-inl.h.

References folly::IOBuf::create(), early_data, fizz::Extension::extension_data, and fizz::Extension::extension_type.

257  {
258  Extension ext;
259  ext.extension_type = ExtensionType::early_data;
260  ext.extension_data = folly::IOBuf::create(0);
261  return ext;
262 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const TicketEarlyData early)
inline

Definition at line 265 of file Extensions-inl.h.

References folly::IOBuf::create(), early_data, fizz::Extension::extension_data, fizz::Extension::extension_type, fizz::TicketEarlyData::max_early_data_size, and fizz::detail::write().

265  {
266  Extension ext;
267  ext.extension_type = ExtensionType::early_data;
268  ext.extension_data = folly::IOBuf::create(0);
269  folly::io::Appender appender(ext.extension_data.get(), 10);
270  detail::write(early.max_early_data_size, appender);
271  return ext;
272 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const Cookie cookie)
inline

Definition at line 275 of file Extensions-inl.h.

References fizz::Cookie::cookie, cookie, folly::IOBuf::create(), fizz::Extension::extension_data, and fizz::Extension::extension_type.

275  {
276  Extension ext;
277  ext.extension_type = ExtensionType::cookie;
278  ext.extension_data = folly::IOBuf::create(0);
279  folly::io::Appender appender(ext.extension_data.get(), 10);
280  detail::writeBuf<uint16_t>(cookie.cookie, appender);
281  return ext;
282 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
StringPiece cookie
template<>
Extension fizz::encodeExtension ( const SupportedVersions versions)
inline

Definition at line 285 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, supported_versions, and fizz::SupportedVersions::versions.

285  {
286  Extension ext;
287  ext.extension_type = ExtensionType::supported_versions;
288  ext.extension_data = folly::IOBuf::create(0);
289  folly::io::Appender appender(ext.extension_data.get(), 10);
290  detail::writeVector<uint8_t>(versions.versions, appender);
291  return ext;
292 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const ServerSupportedVersions versions)
inline

Definition at line 295 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, fizz::ServerSupportedVersions::selected_version, supported_versions, and fizz::detail::write().

295  {
296  Extension ext;
297  ext.extension_type = ExtensionType::supported_versions;
298  ext.extension_data = folly::IOBuf::create(0);
299  folly::io::Appender appender(ext.extension_data.get(), 10);
300  detail::write(versions.selected_version, appender);
301  return ext;
302 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const PskKeyExchangeModes modes)
inline

Definition at line 305 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, fizz::PskKeyExchangeModes::modes, and psk_key_exchange_modes.

305  {
306  Extension ext;
307  ext.extension_type = ExtensionType::psk_key_exchange_modes;
308  ext.extension_data = folly::IOBuf::create(0);
309  folly::io::Appender appender(ext.extension_data.get(), 10);
310  detail::writeVector<uint8_t>(modes.modes, appender);
311  return ext;
312 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const ProtocolNameList names)
inline

Definition at line 315 of file Extensions-inl.h.

References application_layer_protocol_negotiation, folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, and fizz::ProtocolNameList::protocol_name_list.

315  {
316  Extension ext;
317  ext.extension_type = ExtensionType::application_layer_protocol_negotiation;
318  ext.extension_data = folly::IOBuf::create(0);
319  folly::io::Appender appender(ext.extension_data.get(), 10);
320  detail::writeVector<uint16_t>(names.protocol_name_list, appender);
321  return ext;
322 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const ServerNameList names)
inline

Definition at line 325 of file Extensions-inl.h.

References folly::IOBuf::create(), fizz::Extension::extension_data, fizz::Extension::extension_type, server_name, and fizz::ServerNameList::server_name_list.

325  {
326  Extension ext;
327  ext.extension_type = ExtensionType::server_name;
328  ext.extension_data = folly::IOBuf::create(0);
329  folly::io::Appender appender(ext.extension_data.get(), 10);
330  detail::writeVector<uint16_t>(names.server_name_list, appender);
331  return ext;
332 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<>
Extension fizz::encodeExtension ( const CertificateAuthorities authorities)
inline

Definition at line 335 of file Extensions-inl.h.

References fizz::CertificateAuthorities::authorities, certificate_authorities, folly::IOBuf::create(), fizz::Extension::extension_data, and fizz::Extension::extension_type.

335  {
336  Extension ext;
337  ext.extension_type = ExtensionType::certificate_authorities;
338  ext.extension_data = folly::IOBuf::create(0);
339  folly::io::Appender appender(ext.extension_data.get(), 10);
340  detail::writeVector<uint16_t>(authorities.authorities, appender);
341  return ext;
342 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
StringPiece authorities
template<>
Extension fizz::encodeExtension ( const CertificateCompressionAlgorithms cca)
inline

Definition at line 345 of file Extensions-inl.h.

References fizz::CertificateCompressionAlgorithms::algorithms, compress_certificate, folly::IOBuf::create(), fizz::Extension::extension_data, and fizz::Extension::extension_type.

345  {
346  Extension ext;
347  ext.extension_type = ExtensionType::compress_certificate;
348  ext.extension_data = folly::IOBuf::create(0);
349  folly::io::Appender appender(ext.extension_data.get(), 10);
350  detail::writeVector<uint8_t>(cca.algorithms, appender);
351  return ext;
352 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
template<class T >
Buf fizz::encodeHandshake ( T &&  handshakeMsg)

Definition at line 515 of file Types-inl.h.

References folly::IOBuf::create(), encode(), folly::gen::move, fizz::detail::bits24::size, fizz::detail::write(), and fizz::detail::writeBits24().

Referenced by fizz::client::test::ClientProtocolTest::doFinishedFlow(), fizz::sm::encodeAndAddBinders(), fizz::sm::getCertificate(), fizz::sm::getCertificateRequest(), fizz::sm::getCertificateVerify(), fizz::server::test::AeadCookieCipherTest::getClientHello(), fizz::sm::getEarlyDataParams(), fizz::detail::getEmptyAuthenticator(), fizz::server::test::ServerProtocolTest::getEncryptedHandshakeWrite(), fizz::Protocol::getFinished(), fizz::sm::getHelloRetryRequest(), fizz::sm::getHrrKeyExchangers(), fizz::Protocol::getKeyUpdated(), fizz::sm::getServerHello(), fizz::server::getStatelessHelloRetryRequest(), fizz::sm::handleCertMsg(), fizz::ExportedAuthenticator::makeAuthenticator(), fizz::sm::setupSchedulerAndContext(), fizz::client::test::TEST_F(), fizz::server::test::TEST_F(), fizz::ExportedAuthenticator::validate(), and fizz::sm::writeNewSessionTicket().

515  {
516  auto body = encode(std::forward<T>(handshakeMsg));
518  folly::io::Appender appender(buf.get(), 0);
519  constexpr auto handshakeType = std::remove_reference<T>::type::handshake_type;
520  detail::write(handshakeType, appender);
521  detail::writeBits24(body->computeChainDataLength(), appender);
522  buf->prependChain(std::move(body));
523  return buf;
524 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void writeBits24(T len, folly::io::Appender &out)
Definition: Types-inl.h:102
HandshakeType
Definition: Types.h:62
Buf fizz::encodeHkdfLabel ( HkdfLabel &&  label,
const std::string hkdfLabelPrefix 
)
inline

Definition at line 488 of file Types-inl.h.

References folly::IOBuf::copyBuffer(), folly::IOBuf::create(), fizz::test::label, folly::Range< Iter >::size(), and fizz::detail::write().

Referenced by fizz::KeyDerivationImpl< Hash >::expandLabel().

490  {
491  auto labelBuf = folly::IOBuf::copyBuffer(
492  folly::to<std::string>(hkdfLabelPrefix, label.label));
493  auto buf = folly::IOBuf::create(sizeof(label.length) + label.label.size());
494  folly::io::Appender appender(buf.get(), 20);
495  detail::write(label.length, appender);
496  detail::writeBuf<uint8_t>(labelBuf, appender);
497  detail::writeBuf<uint8_t>(label.hash_value, appender);
498  return buf;
499 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
constexpr size_type size() const
Definition: Range.h:431
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
StringPiece label
template<typename T >
std::string fizz::enumToHex ( T  enumValue)

Definition at line 646 of file Types-inl.h.

References folly::Endian::big(), folly::hexlify(), type, and value.

Referenced by fizz::extensions::toString(), and toString().

646  {
647  auto value = folly::Endian::big(
648  static_cast<typename std::underlying_type<T>::type>(enumValue));
650  reinterpret_cast<const uint8_t*>(&value), sizeof(value)));
651 }
PskType type
static T big(T x)
Definition: Bits.h:259
static const char *const value
Definition: Conv.cpp:50
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
std::vector< Extension >::const_iterator fizz::findExtension ( const std::vector< Extension > &  extensions,
ExtensionType  type 
)
inline

Definition at line 15 of file Extensions-inl.h.

Referenced by getExtension(), fizz::test::TestMessages::removeExtension(), fizz::test::TEST_F(), and fizz::client::test::TEST_F().

17  {
18  for (auto it = extensions.begin(); it != extensions.end(); ++it) {
19  if (it->extension_type == type) {
20  return it;
21  }
22  }
23  return extensions.end();
24 }
PskType type
size_t fizz::getBinderLength ( const ClientHello chlo)
inline

Definition at line 354 of file Extensions-inl.h.

References decode_error, fizz::ClientHello::extensions, pre_shared_key, fizz::detail::read(), and uint16_t.

Referenced by fizz::sm::encodeAndAddBinders(), fizz::sm::setupSchedulerAndContext(), and fizz::test::TEST_F().

354  {
355  if (chlo.extensions.empty() ||
356  chlo.extensions.back().extension_type != ExtensionType::pre_shared_key) {
357  throw FizzException(
358  "psk not at end of client hello", AlertDescription::decode_error);
359  }
360  folly::io::Cursor cursor(chlo.extensions.back().extension_data.get());
361  uint16_t identitiesLen;
362  detail::read(identitiesLen, cursor);
363  cursor.skip(identitiesLen);
364  uint16_t binderLen;
365  detail::read(binderLen, cursor);
366  if (cursor.totalLength() != binderLen) {
367  throw FizzException(
368  "malformed binder length", AlertDescription::decode_error);
369  }
370  return sizeof(binderLen) + binderLen;
371 }
static const std::string chlo
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<class T >
folly::Optional< T > fizz::getExtension ( const std::vector< Extension > &  extensions)
inline

Definition at line 27 of file Extensions-inl.h.

References findExtension(), and folly::none.

28  {
29  auto it = findExtension(extensions, T::extension_type);
30  if (it == extensions.end()) {
31  return folly::none;
32  }
33  folly::io::Cursor cs{it->extension_data.get()};
34  auto ret = getExtension<T>(cs);
35  if (!cs.isAtEnd()) {
36  throw std::runtime_error("didn't read entire extension");
37  }
38  return ret;
39 }
std::vector< Extension >::const_iterator findExtension(const std::vector< Extension > &extensions, ExtensionType type)
constexpr None none
Definition: Optional.h:87
template<>
SignatureAlgorithms fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 42 of file Extensions-inl.h.

42  {
43  SignatureAlgorithms sigs;
44  detail::readVector<uint16_t>(sigs.supported_signature_algorithms, cs);
45  return sigs;
46 }
template<>
SupportedGroups fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 49 of file Extensions-inl.h.

References fizz::SupportedGroups::named_group_list.

49  {
50  SupportedGroups groups;
51  detail::readVector<uint16_t>(groups.named_group_list, cs);
52  return groups;
53 }
template<>
folly::Optional< ClientKeyShare > fizz::getExtension ( const std::vector< Extension > &  extensions)
inline

Definition at line 56 of file Extensions-inl.h.

References fizz::ClientKeyShare::client_shares, findExtension(), fizz::extensions::TokenBindingParameters::key_parameters_list, key_share, key_share_old, folly::gen::move, folly::none, params, fizz::ClientKeyShare::preDraft23, fizz::detail::read(), folly::pushmi::operators::share, token_binding, and fizz::extensions::TokenBindingParameters::version.

57  {
58  ClientKeyShare share;
59  auto it = findExtension(extensions, ExtensionType::key_share);
60  if (it == extensions.end()) {
61  it = findExtension(extensions, ExtensionType::key_share_old);
62  if (it == extensions.end()) {
63  return folly::none;
64  }
65  share.preDraft23 = true;
66  }
67  folly::io::Cursor cs{it->extension_data.get()};
68  detail::readVector<uint16_t>(share.client_shares, cs);
69  return std::move(share);
70 }
std::vector< Extension >::const_iterator findExtension(const std::vector< Extension > &extensions, ExtensionType type)
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr None none
Definition: Optional.h:87
template<>
folly::Optional<extensions::TokenBindingParameters> fizz::getExtension ( const std::vector< Extension > &  extensions)
inline

Definition at line 99 of file Types.cpp.

References fizz::ClientKeyShare::client_shares, findExtension(), fizz::extensions::TokenBindingParameters::key_parameters_list, key_share, key_share_old, folly::gen::move, folly::none, params, fizz::ClientKeyShare::preDraft23, fizz::detail::read(), folly::pushmi::operators::share, token_binding, and fizz::extensions::TokenBindingParameters::version.

100  {
101  auto it = findExtension(extensions, ExtensionType::token_binding);
102  if (it == extensions.end()) {
103  return folly::none;
104  }
106  folly::io::Cursor cursor(it->extension_data.get());
107  detail::read(params.version, cursor);
108  detail::readVector<uint8_t>(params.key_parameters_list, cursor);
109  return std::move(params);
110 }
std::vector< Extension >::const_iterator findExtension(const std::vector< Extension > &extensions, ExtensionType type)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
TokenBindingProtocolVersion version
Definition: Types.h:42
constexpr Params params[]
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
std::vector< TokenBindingKeyParameters > key_parameters_list
Definition: Types.h:43
constexpr None none
Definition: Optional.h:87
template<>
ServerKeyShare fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 73 of file Extensions-inl.h.

References fizz::detail::read(), fizz::ServerKeyShare::server_share, and folly::pushmi::operators::share.

73  {
74  ServerKeyShare share;
75  detail::read(share.server_share, cs);
76  return share;
77 }
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
HelloRetryRequestKeyShare fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 80 of file Extensions-inl.h.

References fizz::detail::read(), fizz::HelloRetryRequestKeyShare::selected_group, and folly::pushmi::operators::share.

80  {
81  HelloRetryRequestKeyShare share;
82  detail::read(share.selected_group, cs);
83  return share;
84 }
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
ClientPresharedKey fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 87 of file Extensions-inl.h.

References fizz::ClientPresharedKey::binders, fizz::ClientPresharedKey::identities, and folly::pushmi::operators::share.

87  {
88  ClientPresharedKey share;
89  detail::readVector<uint16_t>(share.identities, cs);
90  detail::readVector<uint16_t>(share.binders, cs);
91  return share;
92 }
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
template<>
ServerPresharedKey fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 95 of file Extensions-inl.h.

References fizz::detail::read(), fizz::ServerPresharedKey::selected_identity, and folly::pushmi::operators::share.

95  {
96  ServerPresharedKey share;
97  detail::read(share.selected_identity, cs);
98  return share;
99 }
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
folly::Optional<TokenBindingParameters> fizz::getExtension ( const std::vector< Extension > &  extensions)

Definition at line 99 of file Types.cpp.

100  {
101  auto it = findExtension(extensions, ExtensionType::token_binding);
102  if (it == extensions.end()) {
103  return folly::none;
104  }
106  folly::io::Cursor cursor(it->extension_data.get());
107  detail::read(params.version, cursor);
108  detail::readVector<uint8_t>(params.key_parameters_list, cursor);
109  return std::move(params);
110 }
std::vector< Extension >::const_iterator findExtension(const std::vector< Extension > &extensions, ExtensionType type)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
TokenBindingProtocolVersion version
Definition: Types.h:42
constexpr Params params[]
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
std::vector< TokenBindingKeyParameters > key_parameters_list
Definition: Types.h:43
constexpr None none
Definition: Optional.h:87
template<>
ClientEarlyData fizz::getExtension ( folly::io::Cursor )
inline

Definition at line 102 of file Extensions-inl.h.

102  {
103  return ClientEarlyData();
104 }
template<>
ServerEarlyData fizz::getExtension ( folly::io::Cursor )
inline

Definition at line 107 of file Extensions-inl.h.

107  {
108  return ServerEarlyData();
109 }
template<>
TicketEarlyData fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 112 of file Extensions-inl.h.

References fizz::TicketEarlyData::max_early_data_size, and fizz::detail::read().

112  {
113  TicketEarlyData early;
114  detail::read(early.max_early_data_size, cs);
115  return early;
116 }
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
Cookie fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 119 of file Extensions-inl.h.

References cookie, and fizz::Cookie::cookie.

119  {
120  Cookie cookie;
121  detail::readBuf<uint16_t>(cookie.cookie, cs);
122  return cookie;
123 }
StringPiece cookie
template<>
SupportedVersions fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 126 of file Extensions-inl.h.

References fizz::SupportedVersions::versions.

126  {
127  SupportedVersions versions;
128  detail::readVector<uint8_t>(versions.versions, cs);
129  return versions;
130 }
template<>
ServerSupportedVersions fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 133 of file Extensions-inl.h.

References fizz::detail::read(), and fizz::ServerSupportedVersions::selected_version.

133  {
134  ServerSupportedVersions versions;
135  detail::read(versions.selected_version, cs);
136  return versions;
137 }
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
template<>
PskKeyExchangeModes fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 140 of file Extensions-inl.h.

References fizz::PskKeyExchangeModes::modes.

140  {
141  PskKeyExchangeModes modes;
142  detail::readVector<uint8_t>(modes.modes, cs);
143  return modes;
144 }
template<>
ProtocolNameList fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 147 of file Extensions-inl.h.

References fizz::ProtocolNameList::protocol_name_list.

147  {
148  ProtocolNameList names;
149  detail::readVector<uint16_t>(names.protocol_name_list, cs);
150  return names;
151 }
template<>
ServerNameList fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 154 of file Extensions-inl.h.

References fizz::ServerNameList::server_name_list.

154  {
155  ServerNameList names;
156  detail::readVector<uint16_t>(names.server_name_list, cs);
157  return names;
158 }
template<>
CertificateAuthorities fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 161 of file Extensions-inl.h.

References authorities, and fizz::CertificateAuthorities::authorities.

161  {
162  CertificateAuthorities authorities;
163  detail::readVector<uint16_t>(authorities.authorities, cs);
164  return authorities;
165 }
StringPiece authorities
template<>
CertificateCompressionAlgorithms fizz::getExtension ( folly::io::Cursor cs)
inline

Definition at line 168 of file Extensions-inl.h.

References fizz::CertificateCompressionAlgorithms::algorithms, and fizz::SignatureAlgorithms::supported_signature_algorithms.

168  {
169  CertificateCompressionAlgorithms cca;
170  detail::readVector<uint8_t>(cca.algorithms, cs);
171  return cca;
172 }
HashFunction fizz::getHashFunction ( CipherSuite  cipher)

Definition at line 13 of file Types.cpp.

References Sha256, Sha384, TLS_AES_128_GCM_SHA256, TLS_AES_128_OCB_SHA256_EXPERIMENTAL, TLS_AES_256_GCM_SHA384, and TLS_CHACHA20_POLY1305_SHA256.

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

13  {
14  switch (cipher) {
15  case CipherSuite::TLS_AES_128_GCM_SHA256:
16  case CipherSuite::TLS_AES_128_OCB_SHA256_EXPERIMENTAL:
17  case CipherSuite::TLS_CHACHA20_POLY1305_SHA256:
18  return HashFunction::Sha256;
19  case CipherSuite::TLS_AES_256_GCM_SHA384:
20  return HashFunction::Sha384;
21  }
22  throw std::runtime_error("unknown cipher suite");
23 }
CipherSuite cipher
size_t fizz::getHashSize ( HashFunction  hash)

Definition at line 25 of file Types.cpp.

References Sha256, and Sha384.

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

25  {
26  switch (hash) {
27  case HashFunction::Sha256:
28  return 32;
29  case HashFunction::Sha384:
30  return 48;
31  }
32  throw std::runtime_error("unknown hash function");
33 }
ProtocolVersion fizz::getRealDraftVersion ( ProtocolVersion  version)

Definition at line 16 of file Types.cpp.

References tls_1_3, tls_1_3_20, tls_1_3_20_fb, tls_1_3_21, tls_1_3_21_fb, tls_1_3_22, tls_1_3_22_fb, tls_1_3_23, tls_1_3_23_fb, tls_1_3_26, tls_1_3_26_fb, tls_1_3_28, and toString().

Referenced by fizz::sm::generateTicket(), fizz::sm::getCertificateRequest(), fizz::sm::getHelloRetryRequest(), fizz::sm::getServerHello(), fizz::sm::negotiateGroup(), fizz::EncryptedReadRecordLayer::setProtocolVersion(), and fizz::WriteRecordLayer::setProtocolVersion().

16  {
17  switch (version) {
18  case ProtocolVersion::tls_1_3:
19  return ProtocolVersion::tls_1_3;
20  case ProtocolVersion::tls_1_3_20:
21  case ProtocolVersion::tls_1_3_20_fb:
22  return ProtocolVersion::tls_1_3_20;
23  case ProtocolVersion::tls_1_3_21:
24  case ProtocolVersion::tls_1_3_21_fb:
25  return ProtocolVersion::tls_1_3_21;
26  case ProtocolVersion::tls_1_3_22:
27  case ProtocolVersion::tls_1_3_22_fb:
28  return ProtocolVersion::tls_1_3_22;
29  case ProtocolVersion::tls_1_3_23:
30  case ProtocolVersion::tls_1_3_23_fb:
31  return ProtocolVersion::tls_1_3_23;
32  case ProtocolVersion::tls_1_3_26:
33  case ProtocolVersion::tls_1_3_26_fb:
34  return ProtocolVersion::tls_1_3_26;
35  case ProtocolVersion::tls_1_3_28:
36  return ProtocolVersion::tls_1_3_28;
37  default:
38  throw std::runtime_error(folly::to<std::string>(
39  "getRealDraftVersion() called with ", toString(version)));
40  }
41 }
std::string toString(CertificateCompressionAlgorithm algo)
Definition: Types.cpp:243
ProtocolVersion version
template<>
CipherSuite fizz::parse ( folly::StringPiece  s)
inline

Definition at line 6 of file Parse-inl.h.

6  {
7  static const std::map<folly::StringPiece, CipherSuite> stringToCiphers = {
8  {"TLS_AES_128_GCM_SHA256", CipherSuite::TLS_AES_128_GCM_SHA256},
9  {"TLS_AES_256_GCM_SHA384", CipherSuite::TLS_AES_256_GCM_SHA384},
10  {"TLS_CHACHA20_POLY1305_SHA256",
11  CipherSuite::TLS_CHACHA20_POLY1305_SHA256},
12  {"TLS_AES_128_OCB_SHA256_EXPERIMENTAL",
13  CipherSuite::TLS_AES_128_OCB_SHA256_EXPERIMENTAL}};
14 
15  auto location = stringToCiphers.find(s);
16  if (location != stringToCiphers.end()) {
17  return location->second;
18  }
19 
20  throw std::runtime_error(folly::to<std::string>("Unknown cipher suite: ", s));
21 }
template<class T >
T fizz::parse ( folly::StringPiece  s)
inline

Definition at line 6 of file Parse-inl.h.

References secp256r1, TLS_AES_128_GCM_SHA256, TLS_AES_128_OCB_SHA256_EXPERIMENTAL, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, and x25519.

6  {
7  static const std::map<folly::StringPiece, CipherSuite> stringToCiphers = {
8  {"TLS_AES_128_GCM_SHA256", CipherSuite::TLS_AES_128_GCM_SHA256},
9  {"TLS_AES_256_GCM_SHA384", CipherSuite::TLS_AES_256_GCM_SHA384},
10  {"TLS_CHACHA20_POLY1305_SHA256",
11  CipherSuite::TLS_CHACHA20_POLY1305_SHA256},
12  {"TLS_AES_128_OCB_SHA256_EXPERIMENTAL",
13  CipherSuite::TLS_AES_128_OCB_SHA256_EXPERIMENTAL}};
14 
15  auto location = stringToCiphers.find(s);
16  if (location != stringToCiphers.end()) {
17  return location->second;
18  }
19 
20  throw std::runtime_error(folly::to<std::string>("Unknown cipher suite: ", s));
21 }
template<>
NamedGroup fizz::parse ( folly::StringPiece  s)
inline

Definition at line 24 of file Parse-inl.h.

References secp256r1, TLS_AES_128_GCM_SHA256, TLS_AES_128_OCB_SHA256_EXPERIMENTAL, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, and x25519.

24  {
25  static const std::map<folly::StringPiece, NamedGroup> stringToGroups = {
26  {"secp256r1", NamedGroup::secp256r1}, {"x25519", NamedGroup::x25519}};
27 
28  auto location = stringToGroups.find(s);
29  if (location != stringToGroups.end()) {
30  return location->second;
31  }
32 
33  throw std::runtime_error(folly::to<std::string>("Unknown named group: ", s));
34 }
template<typename T >
static Param fizz::parse ( Buf  handshakeMsg,
Buf  original 
)
static

Definition at line 68 of file RecordLayer.cpp.

References folly::gen::move.

68  {
69  auto msg = decode<T>(std::move(handshakeMsg));
70  msg.originalEncoding = std::move(original);
71  return std::move(msg);
72 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<>
Param fizz::parse< ServerHello > ( Buf  handshakeMsg,
Buf  original 
)

Definition at line 75 of file RecordLayer.cpp.

References fizz::HelloRetryRequest::cipher_suite, fizz::HelloRetryRequest::extensions, fizz::HelloRetryRequest::HrrRandom, fizz::HelloRetryRequest::legacy_compression_method, fizz::HelloRetryRequest::legacy_session_id_echo, fizz::HelloRetryRequest::legacy_version, folly::gen::move, and fizz::HandshakeStruct< e, t >::originalEncoding.

Referenced by fizz::ReadRecordLayer::decodeHandshakeMessage().

75  {
76  auto shlo = decode<ServerHello>(std::move(handshakeMsg));
77  if (shlo.random == HelloRetryRequest::HrrRandom) {
79  hrr.legacy_version = shlo.legacy_version;
80  hrr.legacy_session_id_echo = std::move(shlo.legacy_session_id_echo);
81  hrr.cipher_suite = shlo.cipher_suite;
82  hrr.legacy_compression_method = shlo.legacy_compression_method;
83  hrr.extensions = std::move(shlo.extensions);
84 
85  hrr.originalEncoding = std::move(original);
86  return std::move(hrr);
87  } else {
88  shlo.originalEncoding = std::move(original);
89  return std::move(shlo);
90  }
91 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static int fizz::passwordCallback ( char *  password,
int  size,
int  ,
void *  data 
)
static

Definition at line 19 of file FizzUtil.cpp.

References data, min, folly::size(), and string.

Referenced by fizz::FizzUtil::decryptPrivateKey(), and folly::SSLContext::passwordCollector().

19  {
20  if (!password || !data || size < 1) {
21  LOG(ERROR) << "invalid password buffer, size is " << size;
22  return 0;
23  }
24  std::string userPassword;
25  static_cast<folly::PasswordInFile*>(data)->getPassword(userPassword, size);
26  if (userPassword.empty()) {
27  LOG(ERROR) << "empty private key password";
28  return 0;
29  }
30  auto length = std::min(static_cast<int>(userPassword.size()), size - 1);
31  memcpy(password, userPassword.data(), length);
32  password[length] = '\0';
33  return length;
34 }
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
LogLevel min
Definition: LogLevel.cpp:30
const char * string
Definition: Conv.cpp:212
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<typename T >
void fizz::setWriteDefaults ( T obj)

Definition at line 21 of file Mocks.h.

References testing::_, fizz::TLSContent::contentType, folly::IOBuf::copyBuffer(), fizz::TLSContent::data, fizz::TLSContent::encryptionLevel, fizz::TLSMessage::fragment, testing::Invoke(), folly::gen::move, ON_CALL, and fizz::TLSMessage::type.

Referenced by fizz::MockPlaintextWriteRecordLayer::setDefaults(), and fizz::MockEncryptedWriteRecordLayer::setDefaults().

21  {
22  ON_CALL(*obj, _write(_)).WillByDefault(Invoke([obj](TLSMessage& msg) {
23  TLSContent content;
24  content.contentType = msg.type;
25  content.encryptionLevel = obj->getEncryptionLevel();
26 
27  if (msg.type == ContentType::application_data) {
28  content.data = folly::IOBuf::copyBuffer("appdata");
29  } else if (msg.type == ContentType::handshake) {
30  content.data = folly::IOBuf::copyBuffer("handshake");
31  } else if (msg.type == ContentType::alert) {
32  auto buf = folly::IOBuf::copyBuffer("alert");
33  buf->prependChain(std::move(msg.fragment));
34  buf->coalesce();
35  content.data = std::move(buf);
36  } else {
37  content.data = std::unique_ptr<folly::IOBuf>();
38  }
39  return content;
40  }));
41 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define ON_CALL(obj, call)
const internal::AnythingMatcher _
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
std::string fizz::toString ( fizz::server::CertificateStorage  storage)

Definition at line 12 of file TicketCodec.cpp.

References None.

12  {
14  switch (storage) {
15  case CertificateStorage::None:
16  return "None";
17  case CertificateStorage::X509:
18  return "X509";
19  case CertificateStorage::IdentityOnly:
20  return "IdentityOnly";
21  default:
22  return "Unknown storage";
23  }
24 }
folly::StringPiece fizz::toString ( Event  event)

Definition at line 12 of file Events.cpp.

References Accept, Alert, AppClose, AppData, AppWrite, Certificate, CertificateRequest, CertificateVerify, ClientHello, CompressedCertificate, Connect, EarlyAppWrite, EncryptedExtensions, EndOfEarlyData, Finished, HelloRetryRequest, KeyUpdate, NewSessionTicket, NUM_EVENTS, ServerHello, and WriteNewSessionTicket.

12  {
13  switch (event) {
14  case Event::ClientHello:
15  return "ClientHello";
16  case Event::ServerHello:
17  return "ServerHello";
18  case Event::EndOfEarlyData:
19  return "EndOfEarlyData";
20  case Event::HelloRetryRequest:
21  return "HelloRetryRequest";
22  case Event::EncryptedExtensions:
23  return "EncryptedExtensions";
24  case Event::CertificateRequest:
25  return "CertificateRequest";
26  case Event::Certificate:
27  return "Certificate";
28  case Event::CompressedCertificate:
29  return "CompressedCertificate";
30  case Event::CertificateVerify:
31  return "CertificateVerify";
32  case Event::Finished:
33  return "Finished";
34  case Event::NewSessionTicket:
35  return "NewSessionTicket";
36  case Event::KeyUpdate:
37  return "KeyUpdate";
38  case Event::Alert:
39  return "Alert";
40  case Event::Accept:
41  return "Accept";
42  case Event::Connect:
43  return "Connect";
44  case Event::AppData:
45  return "AppData";
46  case Event::EarlyAppWrite:
47  return "EarlyAppWrite";
48  case Event::AppWrite:
49  return "AppWrite";
50  case Event::AppClose:
51  return "AppClose";
52  case Event::WriteNewSessionTicket:
53  return "WriteNewSessionTicket";
54  case Event::NUM_EVENTS:
55  return "Invalid event NUM_EVENTS";
56  }
57  return "Unknown event";
58 }
folly::StringPiece fizz::toString ( ReplayCacheResult  result)

Definition at line 15 of file ReplayCache.cpp.

References fizz::server::DefinitelyReplay, fizz::server::MaybeReplay, fizz::server::NotChecked, and fizz::server::NotReplay.

15  {
16  switch (result) {
18  return "NotChecked";
20  return "NotReplay";
22  return "MaybeReplay";
24  return "DefinitelyReplay";
25  }
26  return "Invalid ReplayCacheResult";
27 }
folly::StringPiece fizz::toString ( StateEnum  state)

Definition at line 16 of file State.cpp.

References Error.

Referenced by fizz::Protocol::checkAllowedExtensions(), fizz::ZlibCertificateDecompressor::decompress(), folly::CustomLogFormatter::formatMessage(), fizz::sm::generateTicket(), fizz::sm::getAndValidateVersionAndCipher(), fizz::sm::getCertificateRequest(), fizz::CertDecompressionManager::getDecompressor(), fizz::EncryptedReadRecordLayer::getDecryptedBuf(), getRealDraftVersion(), fizz::sm::handleCertMsg(), fizz::server::detail::handleInvalidEvent(), fizz::client::detail::handleInvalidEvent(), fizz::server::operator<<(), fizz::client::operator<<(), fizz::ReadRecordLayer::readEvent(), TEST(), fizz::sm::EventHandlerBase< SM, state, event >::Transition(), fizz::sm::validatePsk(), and fizz::extensions::Validator::validateTokenBinding().

16  {
17  switch (state) {
18  case StateEnum::Uninitialized:
19  return "Uninitialized";
20  case StateEnum::ExpectingServerHello:
21  return "ExpectingServerHello";
22  case StateEnum::ExpectingEncryptedExtensions:
23  return "ExpectingEncryptedExtensions";
24  case StateEnum::ExpectingCertificate:
25  return "ExpectingCertificate";
26  case StateEnum::ExpectingCertificateVerify:
27  return "ExpectingCertificateVerify";
28  case StateEnum::ExpectingFinished:
29  return "ExpectingFinished";
30  case StateEnum::Established:
31  return "Established";
32  case StateEnum::Error:
33  return "Error";
34  case StateEnum::NUM_STATES:
35  return "Invalid state NUM_STATES";
36  }
37  return "Invalid state";
38 }
error_stage Error
state
Definition: http_parser.c:272
folly::StringPiece fizz::toString ( HashFunction  hash)

Definition at line 35 of file Types.cpp.

References Sha256, and Sha384.

35  {
36  switch (hash) {
37  case HashFunction::Sha256:
38  return "Sha256";
39  case HashFunction::Sha384:
40  return "Sha384";
41  }
42  return "Invalid HashFunction";
43 }
folly::StringPiece fizz::toString ( ClientAuthType  auth)

Definition at line 40 of file State.cpp.

40  {
41  switch (auth) {
42  case ClientAuthType::NotRequested:
43  return "NotRequested";
44  case ClientAuthType::Sent:
45  return "Sent";
46  case ClientAuthType::RequestedNoMatch:
47  return "RequestedNoMatch";
48  case ClientAuthType::Stored:
49  return "Stored";
50  }
51  return "Invalid client auth type";
52 }
std::string fizz::toString ( ProtocolVersion  version)

Definition at line 43 of file Types.cpp.

References enumToHex(), tls_1_0, tls_1_1, tls_1_2, tls_1_3, tls_1_3_20, tls_1_3_20_fb, tls_1_3_21, tls_1_3_21_fb, tls_1_3_22, tls_1_3_22_fb, tls_1_3_23, tls_1_3_23_fb, tls_1_3_26, tls_1_3_26_fb, and tls_1_3_28.

43  {
44  switch (version) {
45  case ProtocolVersion::tls_1_0:
46  return "TLSv1.0";
47  case ProtocolVersion::tls_1_1:
48  return "TLSv1.1";
49  case ProtocolVersion::tls_1_2:
50  return "TLSv1.2";
51  case ProtocolVersion::tls_1_3:
52  return "TLSv1.3";
53  case ProtocolVersion::tls_1_3_20:
54  return "TLSv1.3-draft-20";
55  case ProtocolVersion::tls_1_3_20_fb:
56  return "TLSv1.3-draft-20-fb";
57  case ProtocolVersion::tls_1_3_21:
58  return "TLSv1.3-draft-21";
59  case ProtocolVersion::tls_1_3_21_fb:
60  return "TLSv1.3-draft-21-fb";
61  case ProtocolVersion::tls_1_3_22:
62  return "TLSv1.3-draft-22";
63  case ProtocolVersion::tls_1_3_22_fb:
64  return "TLSv1.3-draft-22-fb";
65  case ProtocolVersion::tls_1_3_23:
66  return "TLSv1.3-draft-23";
67  case ProtocolVersion::tls_1_3_23_fb:
68  return "TLSv1.3-draft-23-fb";
69  case ProtocolVersion::tls_1_3_26:
70  return "TLSv1.3-draft-26";
71  case ProtocolVersion::tls_1_3_26_fb:
72  return "TLSv1.3-draft-26-fb";
73  case ProtocolVersion::tls_1_3_28:
74  return "TLSv1.3-draft-28";
75  }
76  return enumToHex(version);
77 }
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
ProtocolVersion version
folly::StringPiece fizz::toString ( PskType  pskType)

Definition at line 45 of file Types.cpp.

References External, NotAttempted, NotSupported, Rejected, and Resumption.

45  {
46  switch (pskType) {
47  case PskType::NotSupported:
48  return "NotSupported";
49  case PskType::NotAttempted:
50  return "NotAttempted";
51  case PskType::Rejected:
52  return "Rejected";
53  case PskType::External:
54  return "External";
55  case PskType::Resumption:
56  return "Resumption";
57  }
58  return "Invalid PskType";
59 }
folly::StringPiece fizz::toString ( KeyExchangeType  kexType)

Definition at line 61 of file Types.cpp.

References HelloRetryRequest, None, and OneRtt.

61  {
62  switch (kexType) {
63  case KeyExchangeType::None:
64  return "None";
65  case KeyExchangeType::OneRtt:
66  return "OneRtt";
67  case KeyExchangeType::HelloRetryRequest:
68  return "HelloRetryRequest";
69  }
70  return "Invalid kex type";
71 }
folly::StringPiece fizz::toString ( EarlyDataType  earlyDataType)

Definition at line 73 of file Types.cpp.

References Accepted, Attempted, NotAttempted, and Rejected.

73  {
74  switch (earlyDataType) {
75  case EarlyDataType::NotAttempted:
76  return "NotAttempted";
77  case EarlyDataType::Attempted:
78  return "Attempted";
79  case EarlyDataType::Rejected:
80  return "Rejected";
81  case EarlyDataType::Accepted:
82  return "Accepted";
83  }
84  return "Invalid EarlyDataType";
85 }
std::string fizz::toString ( ExtensionType  extType)

Definition at line 79 of file Types.cpp.

References application_layer_protocol_negotiation, certificate_authorities, compress_certificate, cookie, early_data, enumToHex(), key_share, key_share_old, post_handshake_auth, pre_shared_key, psk_key_exchange_modes, quic_transport_parameters, server_name, signature_algorithms, signature_algorithms_cert, supported_groups, supported_versions, and token_binding.

79  {
80  switch (extType) {
81  case ExtensionType::server_name:
82  return "server_name";
83  case ExtensionType::supported_groups:
84  return "supported_groups";
85  case ExtensionType::signature_algorithms:
86  return "signature_algorithms";
87  case ExtensionType::application_layer_protocol_negotiation:
88  return "application_layer_protocol_negotiation";
89  case ExtensionType::token_binding:
90  return "token_binding";
91  case ExtensionType::quic_transport_parameters:
92  return "quic_transport_parameters";
93  case ExtensionType::key_share_old:
94  return "key_share_old";
95  case ExtensionType::pre_shared_key:
96  return "pre_shared_key";
97  case ExtensionType::early_data:
98  return "early_data";
99  case ExtensionType::supported_versions:
100  return "supported_version";
102  return "cookie";
103  case ExtensionType::psk_key_exchange_modes:
104  return "psk_key_exchange_modes";
105  case ExtensionType::certificate_authorities:
106  return "certificate_authorities";
107  case ExtensionType::post_handshake_auth:
108  return "post_handshake_auth";
109  case ExtensionType::signature_algorithms_cert:
110  return "signature_algorithms_cert";
111  case ExtensionType::key_share:
112  return "key_share";
113  case ExtensionType::compress_certificate:
114  return "compress_certificate";
115  }
116  return enumToHex(extType);
117 }
StringPiece cookie
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
std::string fizz::toString ( AlertDescription  alertDesc)

Definition at line 119 of file Types.cpp.

References access_denied, bad_certificate, bad_certificate_hash_value, bad_certificate_status_response, bad_record_mac, certificate_expired, certificate_required, certificate_revoked, certificate_unknown, certificate_unobtainable, close_notify, decode_error, decrypt_error, end_of_early_data, enumToHex(), handshake_failure, illegal_parameter, inappropriate_fallback, insufficient_security, internal_error, missing_extension, protocol_version, record_overflow, unexpected_message, unknown_ca, unknown_psk_identity, unrecognized_name, unsupported_certificate, unsupported_extension, and user_canceled.

119  {
120  switch (alertDesc) {
121  case AlertDescription::close_notify:
122  return "close_notify";
123  case AlertDescription::end_of_early_data:
124  return "end_of_early_data";
125  case AlertDescription::unexpected_message:
126  return "unexpected_message";
127  case AlertDescription::bad_record_mac:
128  return "bad_record_mac";
129  case AlertDescription::record_overflow:
130  return "record_overflow";
131  case AlertDescription::handshake_failure:
132  return "handshake_failure";
133  case AlertDescription::bad_certificate:
134  return "bad_certificate";
135  case AlertDescription::unsupported_certificate:
136  return "unsupported_certificate";
137  case AlertDescription::certificate_revoked:
138  return "certificate_revoked";
139  case AlertDescription::certificate_expired:
140  return "certificate_expired";
141  case AlertDescription::certificate_unknown:
142  return "certificate_unknown";
143  case AlertDescription::illegal_parameter:
144  return "illegal_parameter";
145  case AlertDescription::unknown_ca:
146  return "unknown_ca";
147  case AlertDescription::access_denied:
148  return "access_denied";
149  case AlertDescription::decode_error:
150  return "decode_error";
151  case AlertDescription::decrypt_error:
152  return "decrypt_error";
153  case AlertDescription::protocol_version:
154  return "protocol_version";
155  case AlertDescription::insufficient_security:
156  return "insufficient_security";
157  case AlertDescription::internal_error:
158  return "internal_error";
159  case AlertDescription::inappropriate_fallback:
160  return "inappropriate_fallback";
161  case AlertDescription::user_canceled:
162  return "user_canceled";
163  case AlertDescription::missing_extension:
164  return "missing_extension";
165  case AlertDescription::unsupported_extension:
166  return "unsupported_extension";
167  case AlertDescription::certificate_unobtainable:
168  return "certificate_unobtainable";
169  case AlertDescription::unrecognized_name:
170  return "unrecognized_name";
171  case AlertDescription::bad_certificate_status_response:
172  return "bad_certificate_status_response";
173  case AlertDescription::bad_certificate_hash_value:
174  return "bad_certificate_hash_value";
175  case AlertDescription::unknown_psk_identity:
176  return "unknown_psk_identity";
177  case AlertDescription::certificate_required:
178  return "certificate_required";
179  }
180  return enumToHex(alertDesc);
181 }
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
std::string fizz::toString ( CipherSuite  cipher)

Definition at line 183 of file Types.cpp.

References enumToHex(), TLS_AES_128_GCM_SHA256, TLS_AES_128_OCB_SHA256_EXPERIMENTAL, TLS_AES_256_GCM_SHA384, and TLS_CHACHA20_POLY1305_SHA256.

183  {
184  switch (cipher) {
185  case CipherSuite::TLS_AES_128_GCM_SHA256:
186  return "TLS_AES_128_GCM_SHA256";
187  case CipherSuite::TLS_AES_256_GCM_SHA384:
188  return "TLS_AES_256_GCM_SHA384";
189  case CipherSuite::TLS_CHACHA20_POLY1305_SHA256:
190  return "TLS_CHACHA20_POLY1305_SHA256";
191  case CipherSuite::TLS_AES_128_OCB_SHA256_EXPERIMENTAL:
192  return "TLS_AES_128_OCB_SHA256_EXPERIMENTAL";
193  }
194  return enumToHex(cipher);
195 }
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
CipherSuite cipher
std::string fizz::toString ( PskKeyExchangeMode  pskKeMode)

Definition at line 197 of file Types.cpp.

References enumToHex(), psk_dhe_ke, and psk_ke.

197  {
198  switch (pskKeMode) {
199  case PskKeyExchangeMode::psk_ke:
200  return "psk_ke";
201  case PskKeyExchangeMode::psk_dhe_ke:
202  return "psk_dhe_ke";
203  }
204  return enumToHex(pskKeMode);
205 }
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
std::string fizz::toString ( SignatureScheme  sigScheme)

Definition at line 207 of file Types.cpp.

References ecdsa_secp256r1_sha256, ecdsa_secp384r1_sha384, ecdsa_secp521r1_sha512, ed25519, ed448, enumToHex(), rsa_pss_sha256, rsa_pss_sha384, and rsa_pss_sha512.

207  {
208  switch (sigScheme) {
209  case SignatureScheme::ecdsa_secp256r1_sha256:
210  return "ecdsa_secp256r1_sha256";
211  case SignatureScheme::ecdsa_secp384r1_sha384:
212  return "ecdsa_secp384r1_sha384";
213  case SignatureScheme::ecdsa_secp521r1_sha512:
214  return "ecdsa_secp521r1_sha512";
215  case SignatureScheme::rsa_pss_sha256:
216  return "rsa_pss_sha256";
217  case SignatureScheme::rsa_pss_sha384:
218  return "rsa_pss_sha384";
219  case SignatureScheme::rsa_pss_sha512:
220  return "rsa_pss_sha512";
221  case SignatureScheme::ed25519:
222  return "ed25519";
223  case SignatureScheme::ed448:
224  return "ed448";
225  }
226  return enumToHex(sigScheme);
227 }
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
std::string fizz::toString ( NamedGroup  group)

Definition at line 229 of file Types.cpp.

References enumToHex(), secp256r1, secp384r1, secp521r1, and x25519.

229  {
230  switch (group) {
231  case NamedGroup::secp256r1:
232  return "secp256r1";
233  case NamedGroup::secp384r1:
234  return "secp384r1";
235  case NamedGroup::secp521r1:
236  return "secp521r1";
237  case NamedGroup::x25519:
238  return "x25519";
239  }
240  return enumToHex(group);
241 }
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
Optional< NamedGroup > group
std::string fizz::toString ( CertificateCompressionAlgorithm  algo)

Definition at line 243 of file Types.cpp.

References enumToHex(), and zlib.

243  {
244  switch (algo) {
245  case CertificateCompressionAlgorithm::zlib:
246  return "zlib";
247  }
248  return enumToHex(algo);
249 }
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
folly::StringPiece fizz::toString ( server::StateEnum  state)
folly::StringPiece fizz::toString ( client::StateEnum  )
template<typename Func >
void fizz::transformBuffer ( const folly::IOBuf in,
folly::IOBuf out,
Func  func 
)

Useful when we need to run a function that performs some operation on an IOBuf and then stores the result in another IOBuf. We assume that the caller ensures that out size >= in size. Apart from that you can pass in chained buffers for output or input buffers or even the same buffer. In the case you pass the same buffer, the Func needs to make sure it can safely deal with this case.

Definition at line 38 of file IOBufUtil.h.

References current, folly::IOBuf::length(), min, folly::IOBuf::next(), and folly::IOBuf::writableData().

Referenced by fizz::test::chunkIOBuf(), fizz::detail::decFunc(), fizz::detail::encFunc(), and fizz::test::TEST().

38  {
39  folly::IOBuf* currentOut = &out;
40  size_t offset = 0;
41 
42  for (auto current : in) {
43  size_t currentLength = current.size();
44 
45  while (currentLength != 0) {
46  size_t selected = std::min(
47  static_cast<size_t>(currentOut->length() - offset), currentLength);
48  func(
49  currentOut->writableData() + offset,
50  current.data() + (current.size() - currentLength),
51  selected);
52  currentLength -= selected;
53  offset += selected;
54  if (offset == currentOut->length()) {
55  offset = 0;
56  currentOut = currentOut->next();
57  }
58  }
59  }
60 }
int current
LogLevel min
Definition: LogLevel.cpp:30
uint8_t * writableData()
Definition: IOBuf.h:509
std::size_t length() const
Definition: IOBuf.h:533
IOBuf * next()
Definition: IOBuf.h:600
template<size_t BlockSize, typename Func >
folly::io::RWPrivateCursor fizz::transformBufferBlocks ( const folly::IOBuf in,
folly::IOBuf out,
Func  func 
)

Useful when we need to run a function that performs operations in chunks and transforms data from in -> out, regardless of whether in or out is chained. We assume out size >= in size.

func is expected to take data from some input buffer, do some operation on it and then place the result of the operation into an output buffer. It only should write to output in blocks of size BlockSize. Data from the input buffer must be internally buffered by func if it can not write a full block to output.

Definition at line 75 of file IOBufUtil.h.

References folly::io::detail::CursorBase< Derived, BufType >::isAtEnd(), min, gmock_output_test::output, folly::io::detail::CursorBase< Derived, BufType >::peekBytes(), folly::io::detail::Writable< Derived >::push(), folly::Range< Iter >::size(), folly::io::detail::CursorBase< Derived, BufType >::skip(), and folly::io::RWCursor< access >::writableData().

75  {
76  size_t internallyBuffered = 0;
78  folly::io::Cursor input(&in);
79 
80  // block to handle writes along output buffer boundaries
81  std::array<uint8_t, BlockSize> blockBuffer = {};
82 
83  // ensure buffers are fine
84  while (!input.isAtEnd()) {
85  auto inputRange = input.peekBytes();
86  auto inputLen = inputRange.size();
87  auto outputLen = output.peekBytes().size();
88  if (inputLen + internallyBuffered < BlockSize) {
89  // input doesn't have enough - we can call func and it should
90  // internally buffer.
91  // This should be safe to just internally buffer since we took into
92  // account what was existing in the internal buffer already
93  auto numWritten = func(blockBuffer.data(), inputRange.data(), inputLen);
94  DCHECK_EQ(numWritten, 0) << "expected buffering. wrote " << numWritten;
95  // only update input offsets
96  internallyBuffered += inputLen;
97  input.skip(inputLen);
98  } else if (outputLen < BlockSize) {
99  // we have at least a block to write from input + internal buffer, so
100  // output didn't have enough room in this case
101  // copy a block from input in temp and then push onto output
102  auto numWritten = func(
103  blockBuffer.data(),
104  inputRange.data(),
105  // only provide it the amount needed for one block
106  BlockSize - internallyBuffered);
107  DCHECK_EQ(numWritten, BlockSize)
108  << "did not write full block bs=" << BlockSize
109  << " wrote=" << numWritten;
110 
111  // push the block onto output
112  output.push(blockBuffer.data(), BlockSize);
113 
114  // advance input
115  input.skip(BlockSize - internallyBuffered);
116  internallyBuffered = 0;
117  } else {
118  // we have at least one block that can be written from input to output
119  // calculate shared bytes while taking into account internal buffer
120  auto numSharedBytes = std::min(outputLen, inputLen + internallyBuffered);
121 
122  // this is the number we can safely (and expect) to write to output
123  auto numBlockBytes = numSharedBytes - (numSharedBytes % BlockSize);
124 
125  // try to grab as much from input - we can grab up to BlockSize - 1 more
126  auto maxToTake = (numBlockBytes - internallyBuffered) + (BlockSize - 1);
127  auto numToTake = std::min(inputLen, maxToTake);
128  auto numWritten =
129  func(output.writableData(), inputRange.data(), numToTake);
130 
131  DCHECK_EQ(numWritten, numBlockBytes);
132 
133  // advance cursors
134  input.skip(numToTake);
135  output.skip(numWritten);
136  // recalculate internal buffer state
137  internallyBuffered = (internallyBuffered + numToTake) % BlockSize;
138  }
139  }
140  return output;
141 }
LogLevel min
Definition: LogLevel.cpp:30
void fizz::trimBytes ( folly::IOBuf buf,
folly::MutableByteRange  trimmed 
)

Trims trimmed.size() bytes at the end of a chained IOBuf and fills in trimmed.

Definition at line 15 of file IOBufUtil.cpp.

References folly::Range< Iter >::begin(), folly::IOBuf::countChainElements(), current, folly::IOBuf::data(), i, folly::IOBuf::length(), min, folly::IOBuf::prev(), folly::Range< Iter >::size(), and folly::IOBuf::trimEnd().

Referenced by fizz::detail::evpDecrypt(), and fizz::test::TEST().

15  {
16  auto trim = trimmed.size();
17  size_t currentTrim = trim;
18  IOBuf* current = buf.prev();
19  size_t chainElements = buf.countChainElements();
20  for (size_t i = 0; i < chainElements && currentTrim != 0; ++i) {
21  size_t toTrim =
22  std::min(currentTrim, static_cast<size_t>(current->length()));
23  memcpy(
24  trimmed.begin() + (currentTrim - toTrim),
25  current->data() + (current->length() - toTrim),
26  toTrim);
27  current->trimEnd(toTrim);
28  currentTrim -= toTrim;
29  current = current->prev();
30  }
31 }
constexpr size_type size() const
Definition: Range.h:431
const uint8_t * data() const
Definition: IOBuf.h:499
size_t countChainElements() const
Definition: IOBuf.cpp:493
int current
LogLevel min
Definition: LogLevel.cpp:30
std::size_t length() const
Definition: IOBuf.h:533
IOBuf * prev()
Definition: IOBuf.h:610
constexpr Iter begin() const
Definition: Range.h:452
void trimEnd(std::size_t amount)
Definition: IOBuf.h:718
void fizz::XOR ( folly::ByteRange  first,
folly::MutableByteRange  second 
)

XOR first and second and store the result in second.

Definition at line 33 of file IOBufUtil.cpp.

References i, and folly::Range< Iter >::size().

Referenced by fizz::OpenSSLEVPCipher< EVPImpl >::createIV().

33  {
34  CHECK_EQ(first.size(), second.size());
35  for (size_t i = 0; i < first.size(); ++i) {
36  second[i] ^= first[i];
37  }
38 };
constexpr size_type size() const
Definition: Range.h:431

Variable Documentation

constexpr folly::StringPiece fizz::FakeChangeCipherSpec
Initial value:
{"\x14\x03\x03\x00\x01\x01",
6}

Definition at line 59 of file Types.h.

Referenced by fizz::sm::getCertificateRequest(), fizz::sm::getHrrKeyExchangers(), fizz::sm::handleCertMsg(), and fizz::sm::handleEarlyAppWrite().

constexpr size_t fizz::kEncryptedHeaderSize
static
Initial value:
=
sizeof(ContentType) + sizeof(ProtocolVersion) + sizeof(uint16_t)
error_stage error_description proxygen_error http_status error_direction codec_error call_path uri is_secure using_proxy status_code protocol security_protocol replay_safe local_addr local_port ContentType
ProtocolVersion
Definition: Types.h:24

Definition at line 18 of file EncryptedRecordLayer.cpp.

Referenced by fizz::EncryptedWriteRecordLayer::write().

constexpr size_t fizz::kHandshakeHeaderSize
static
Initial value:
=
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
HandshakeType
Definition: Types.h:62

Definition at line 15 of file RecordLayer.cpp.

constexpr folly::StringPiece fizz::kHkdfLabelPrefix = "tls13 "
const uint32_t fizz::kMaxBufSize = 64 * 1024
static

Buffer size above which we should unset our read callback to apply back pressure on the transport.

Definition at line 28 of file AsyncFizzBase.cpp.

Referenced by fizz::AsyncFizzBase::checkBufLen().

constexpr uint16_t fizz::kMaxEncryptedRecordSize = 0x4000 + 256
static

Definition at line 17 of file EncryptedRecordLayer.cpp.

constexpr size_t fizz::kMaxHandshakeSize = 0x20000
static constexpr uint16_t fizz::kMaxPlaintextRecordSize = 0x4000

Definition at line 17 of file EncryptedRecordLayer.h.

const uint32_t fizz::kMaxReadSize = 4000
static

Definition at line 22 of file AsyncFizzBase.cpp.

Referenced by ProxyService::ProxyHandler::getReadBuffer().

const uint32_t fizz::kMinReadSize = 1460
static

Min and max read buffer sizes when using non-mo

Definition at line 21 of file AsyncFizzBase.cpp.

Referenced by ProxyService::ProxyHandler::getReadBuffer(), and proxygen::HTTPSession::getReadBuffer().

constexpr uint16_t fizz::kMinSuggestedRecordSize = 1500

Definition at line 18 of file EncryptedRecordLayer.h.

constexpr size_t fizz::kPlaintextHeaderSize
static
Initial value:
=
sizeof(ContentType) + sizeof(ProtocolVersion) + sizeof(uint16_t)
error_stage error_description proxygen_error http_status error_direction codec_error call_path uri is_secure using_proxy status_code protocol security_protocol replay_safe local_addr local_port ContentType
ProtocolVersion
Definition: Types.h:24

Definition at line 20 of file PlaintextRecordLayer.cpp.

Referenced by fizz::PlaintextWriteRecordLayer::write().