proxygen
Types.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
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.
7  */
8 
9 #include <fizz/record/Types.h>
10 #include <folly/String.h>
11 
12 namespace fizz {
13 
15 
17  switch (version) {
37  default:
38  throw std::runtime_error(folly::to<std::string>(
39  "getRealDraftVersion() called with ", toString(version)));
40  }
41 }
42 
44  switch (version) {
46  return "TLSv1.0";
48  return "TLSv1.1";
50  return "TLSv1.2";
52  return "TLSv1.3";
54  return "TLSv1.3-draft-20";
56  return "TLSv1.3-draft-20-fb";
58  return "TLSv1.3-draft-21";
60  return "TLSv1.3-draft-21-fb";
62  return "TLSv1.3-draft-22";
64  return "TLSv1.3-draft-22-fb";
66  return "TLSv1.3-draft-23";
68  return "TLSv1.3-draft-23-fb";
70  return "TLSv1.3-draft-26";
72  return "TLSv1.3-draft-26-fb";
74  return "TLSv1.3-draft-28";
75  }
76  return enumToHex(version);
77 }
78 
80  switch (extType) {
82  return "server_name";
84  return "supported_groups";
86  return "signature_algorithms";
88  return "application_layer_protocol_negotiation";
90  return "token_binding";
92  return "quic_transport_parameters";
94  return "key_share_old";
96  return "pre_shared_key";
98  return "early_data";
100  return "supported_version";
102  return "cookie";
104  return "psk_key_exchange_modes";
106  return "certificate_authorities";
108  return "post_handshake_auth";
110  return "signature_algorithms_cert";
112  return "key_share";
114  return "compress_certificate";
115  }
116  return enumToHex(extType);
117 }
118 
120  switch (alertDesc) {
122  return "close_notify";
124  return "end_of_early_data";
126  return "unexpected_message";
128  return "bad_record_mac";
130  return "record_overflow";
132  return "handshake_failure";
134  return "bad_certificate";
136  return "unsupported_certificate";
138  return "certificate_revoked";
140  return "certificate_expired";
142  return "certificate_unknown";
144  return "illegal_parameter";
146  return "unknown_ca";
148  return "access_denied";
150  return "decode_error";
152  return "decrypt_error";
154  return "protocol_version";
156  return "insufficient_security";
158  return "internal_error";
160  return "inappropriate_fallback";
162  return "user_canceled";
164  return "missing_extension";
166  return "unsupported_extension";
168  return "certificate_unobtainable";
170  return "unrecognized_name";
172  return "bad_certificate_status_response";
174  return "bad_certificate_hash_value";
176  return "unknown_psk_identity";
178  return "certificate_required";
179  }
180  return enumToHex(alertDesc);
181 }
182 
184  switch (cipher) {
186  return "TLS_AES_128_GCM_SHA256";
188  return "TLS_AES_256_GCM_SHA384";
190  return "TLS_CHACHA20_POLY1305_SHA256";
192  return "TLS_AES_128_OCB_SHA256_EXPERIMENTAL";
193  }
194  return enumToHex(cipher);
195 }
196 
198  switch (pskKeMode) {
200  return "psk_ke";
202  return "psk_dhe_ke";
203  }
204  return enumToHex(pskKeMode);
205 }
206 
208  switch (sigScheme) {
210  return "ecdsa_secp256r1_sha256";
212  return "ecdsa_secp384r1_sha384";
214  return "ecdsa_secp521r1_sha512";
216  return "rsa_pss_sha256";
218  return "rsa_pss_sha384";
220  return "rsa_pss_sha512";
222  return "ed25519";
224  return "ed448";
225  }
226  return enumToHex(sigScheme);
227 }
228 
230  switch (group) {
232  return "secp256r1";
234  return "secp384r1";
236  return "secp521r1";
237  case NamedGroup::x25519:
238  return "x25519";
239  }
240  return enumToHex(group);
241 }
242 
244  switch (algo) {
246  return "zlib";
247  }
248  return enumToHex(algo);
249 }
250 } // namespace fizz
folly::StringPiece toString(StateEnum state)
Definition: State.cpp:16
static constexpr Random HrrRandom
Definition: Types.h:211
CertificateCompressionAlgorithm
Definition: Types.h:167
NamedGroup
Definition: Types.h:302
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
SignatureScheme
Definition: Types.h:257
CipherSuite
Definition: Types.h:153
CipherSuite cipher
ProtocolVersion
Definition: Types.h:24
ProtocolVersion version
AlertDescription
Definition: Types.h:119
Definition: Actions.h:16
ExtensionType
Definition: Types.h:95
Optional< NamedGroup > group
const char * string
Definition: Conv.cpp:212
ProtocolVersion getRealDraftVersion(ProtocolVersion version)
Definition: Types.cpp:16
PskKeyExchangeMode
Definition: Types.h:163