2 * Copyright (c) 2018-present, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree.
11 #include <fizz/record/Types.h>
12 #include <folly/Optional.h>
16 struct SignatureAlgorithms
{
17 std::vector
<SignatureScheme
> supported_signature_algorithms
;
18 static constexpr ExtensionType extension_type
=
19 ExtensionType::signature_algorithms
;
22 struct SupportedGroups
{
23 std::vector
<NamedGroup
> named_group_list
;
24 static constexpr ExtensionType extension_type
=
25 ExtensionType::supported_groups
;
28 struct KeyShareEntry
{
33 struct ClientKeyShare
{
34 std::vector
<KeyShareEntry
> client_shares
;
35 static constexpr ExtensionType extension_type
= ExtensionType::key_share
;
38 struct ServerKeyShare
{
39 KeyShareEntry server_share
;
40 static constexpr ExtensionType extension_type
= ExtensionType::key_share
;
43 struct HelloRetryRequestKeyShare
{
44 NamedGroup selected_group
;
45 static constexpr ExtensionType extension_type
= ExtensionType::key_share
;
50 uint32_t obfuscated_ticket_age
;
57 struct ClientPresharedKey
{
58 std::vector
<PskIdentity
> identities
;
59 std::vector
<PskBinder
> binders
;
60 static constexpr ExtensionType extension_type
= ExtensionType::pre_shared_key
;
63 struct ServerPresharedKey
{
64 uint16_t selected_identity
;
65 static constexpr ExtensionType extension_type
= ExtensionType::pre_shared_key
;
68 struct ClientEarlyData
{
69 static constexpr ExtensionType extension_type
= ExtensionType::early_data
;
72 struct ServerEarlyData
{
73 static constexpr ExtensionType extension_type
= ExtensionType::early_data
;
76 struct TicketEarlyData
{
77 uint32_t max_early_data_size
;
78 static constexpr ExtensionType extension_type
= ExtensionType::early_data
;
83 static constexpr ExtensionType extension_type
= ExtensionType::cookie
;
86 struct SupportedVersions
{
87 std::vector
<ProtocolVersion
> versions
;
88 static constexpr ExtensionType extension_type
=
89 ExtensionType::supported_versions
;
92 struct ServerSupportedVersions
{
93 ProtocolVersion selected_version
;
94 static constexpr ExtensionType extension_type
=
95 ExtensionType::supported_versions
;
98 struct PskKeyExchangeModes
{
99 std::vector
<PskKeyExchangeMode
> modes
;
100 static constexpr ExtensionType extension_type
=
101 ExtensionType::psk_key_exchange_modes
;
104 struct ProtocolName
{
108 struct ProtocolNameList
{
109 std::vector
<ProtocolName
> protocol_name_list
;
110 static constexpr ExtensionType extension_type
=
111 ExtensionType::application_layer_protocol_negotiation
;
114 enum class ServerNameType
: uint8_t { host_name
= 0 };
118 explicit ServerName(Buf hostnameIn
) : hostname(std::move(hostnameIn
)) {}
120 ServerNameType name_type
{ServerNameType::host_name
};
124 struct ServerNameList
{
126 explicit ServerNameList(ServerName sn
) {
127 server_name_list
.push_back(std::move(sn
));
129 std::vector
<ServerName
> server_name_list
;
130 static constexpr ExtensionType extension_type
= ExtensionType::server_name
;
133 struct DistinguishedName
{
137 struct CertificateAuthorities
{
138 std::vector
<DistinguishedName
> authorities
;
139 static constexpr ExtensionType extension_type
=
140 ExtensionType::certificate_authorities
;
143 struct CertificateCompressionAlgorithms
{
144 std::vector
<CertificateCompressionAlgorithm
> algorithms
;
145 static constexpr ExtensionType extension_type
=
146 ExtensionType::compress_certificate
;
149 struct EchOuterExtensions
{
150 std::vector
<ExtensionType
> extensionTypes
;
151 static constexpr ExtensionType extension_type
=
152 ExtensionType::ech_outer_extensions
;
156 folly::Optional
<T
> getExtension(const std::vector
<Extension
>& extension
);
158 T
getExtension(folly::io::Cursor
& cursor
);
161 Extension
encodeExtension(const T
& t
);
163 std::vector
<Extension
>::const_iterator
findExtension(
164 const std::vector
<Extension
>& extensions
,
167 size_t getBinderLength(const ClientHello
& chlo
);
170 #include <fizz/record/Extensions-inl.h>