proxygen
Types-inl.h
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 <folly/Conv.h>
10 #include <folly/String.h>
11 #include <folly/io/Cursor.h>
12 
13 namespace fizz {
14 namespace detail {
15 
16 // Structure representing a 24 bit type.
17 struct bits24 {
18  static constexpr size_t size = 3;
19 };
20 
21 template <class U>
22 struct Sizer {
23  template <class T>
24  size_t getSize(const typename std::enable_if<
27  T>::type&) {
28  return sizeof(T);
29  }
30 };
31 
32 template <class N>
33 size_t getBufSize(const Buf& buf) {
34  return sizeof(N) + buf->computeChainDataLength();
35 }
36 
37 template <>
38 inline size_t getBufSize<bits24>(const Buf& buf) {
39  return bits24::size + buf->computeChainDataLength();
40 }
41 
42 template <class T>
43 size_t getSize(const T& t) {
44  return Sizer<T>().template getSize<T>(t);
45 }
46 
47 template <>
48 struct Sizer<Extension> {
49  template <class T>
50  size_t getSize(const Extension& proto) {
51  return sizeof(ExtensionType) + getBufSize<uint16_t>(proto.extension_data);
52  }
53 };
54 
55 template <>
57  template <class T>
58  size_t getSize(const CertificateEntry& entry) {
59  size_t len = 0;
60  len += getBufSize<bits24>(entry.cert_data);
61  len += sizeof(uint16_t);
62  for (const auto& ext : entry.extensions) {
63  len += detail::getSize(ext);
64  }
65  return len;
66  }
67 };
68 
69 template <class U>
70 struct Writer {
71  template <class T>
72  void write(
73  const typename std::enable_if<
75  T>::type& in,
76  folly::io::Appender& appender) {
77  using UT = typename std::underlying_type<U>::type;
78  appender.writeBE<UT>(static_cast<UT>(in));
79  }
80 
81  template <class T>
82  void write(
83  const typename std::enable_if<
85  T>::type& in,
86  folly::io::Appender& appender) {
87  appender.writeBE<U>(in);
88  }
89 };
90 
91 template <class T>
92 void checkWithin24bits(const typename std::enable_if<
94  T>::type& value) {
95  const uint32_t UINT24_MAX = 0xFFFFFF;
96  if (value > UINT24_MAX) {
97  throw std::runtime_error("Overflow 24 bit type");
98  }
99 }
100 
101 template <class T>
103  static_assert(sizeof(T) > 3, "Type is too short");
104  checkWithin24bits<T>(len);
105  T lenBE = folly::Endian::big(len);
106  uint8_t* addr = reinterpret_cast<uint8_t*>(&lenBE);
107  uint8_t offset = sizeof(T) - 3;
108  out.push(addr + offset, bits24::size);
109 }
110 
111 template <class T>
112 void write(const T& in, folly::io::Appender& appender) {
113  Writer<T>().template write<T>(in, appender);
114 }
115 
116 template <class N, class T>
117 struct WriterVector {
118  void writeVector(const std::vector<T>& data, folly::io::Appender& out) {
119  // First do a pass to compute the size of the data
120  size_t len = 0;
121  for (const auto& t : data) {
122  len += getSize<T>(t);
123  }
124 
125  out.writeBE<N>(folly::to<N>(len));
126  for (const auto& t : data) {
127  write(t, out);
128  }
129  }
130 };
131 
132 template <class T>
134  void writeVector(const std::vector<T>& data, folly::io::Appender& out) {
135  // First do a pass to compute the size of the data
136  size_t len = 0;
137  for (const auto& t : data) {
138  len += getSize<T>(t);
139  }
140 
141  writeBits24(len, out);
142  for (const auto& t : data) {
143  write(t, out);
144  }
145  }
146 };
147 
148 template <class N, class T>
149 void writeVector(const std::vector<T>& data, folly::io::Appender& out) {
150  return WriterVector<N, T>().writeVector(data, out);
151 }
152 
153 template <class N>
154 void writeBuf(const Buf& buf, folly::io::Appender& out) {
155  if (!buf) {
156  out.writeBE<N>(folly::to<N>(0));
157  return;
158  }
159  out.writeBE<N>(folly::to<N>(buf->computeChainDataLength()));
160  auto current = buf.get();
161  size_t chainElements = buf->countChainElements();
162  for (size_t i = 0; i < chainElements; ++i) {
163  // TODO: fina a better way not to require copying all the buffers into
164  // the cursor
165  out.push(current->data(), current->length());
166  current = current->next();
167  }
168 }
169 
170 template <>
171 struct Writer<Random> {
172  template <class T>
173  void write(const Random& random, folly::io::Appender& out) {
174  out.push(random.data(), random.size());
175  }
176 };
177 
178 template <>
179 inline void writeBuf<bits24>(const Buf& buf, folly::io::Appender& out) {
180  if (!buf) {
181  writeBits24(static_cast<size_t>(0), out);
182  return;
183  }
184  writeBits24(buf->computeChainDataLength(), out);
185  auto current = buf.get();
186  size_t chainElements = buf->countChainElements();
187  for (size_t i = 0; i < chainElements; ++i) {
188  out.push(current->data(), current->length());
189  current = current->next();
190  }
191 }
192 
193 template <>
194 inline void write<Extension>(
195  const Extension& extension,
196  folly::io::Appender& out) {
197  out.writeBE(static_cast<typename std::underlying_type<ExtensionType>::type>(
198  extension.extension_type));
199  writeBuf<uint16_t>(extension.extension_data, out);
200 }
201 
202 template <>
204  const CertificateEntry& entry,
205  folly::io::Appender& out) {
206  writeBuf<detail::bits24>(entry.cert_data, out);
207  writeVector<uint16_t>(entry.extensions, out);
208 }
209 
211  uint32_t data = 0;
212  uint8_t offset = sizeof(data) - 3;
213  uint8_t* addr = reinterpret_cast<uint8_t*>(&data);
214  cursor.pull(addr + offset, 3);
215  uint32_t length = folly::Endian::big(data);
216  return length;
217 }
218 
219 template <class N>
220 size_t readBuf(Buf& buf, folly::io::Cursor& cursor) {
221  auto len = cursor.readBE<N>();
222  cursor.clone(buf, len);
223  return sizeof(N) + len;
224 }
225 
226 template <>
227 inline size_t readBuf<bits24>(Buf& buf, folly::io::Cursor& cursor) {
228  auto len = readBits24(cursor);
229  cursor.clone(buf, len);
230  return bits24::size + len;
231 }
232 
233 template <class U>
234 struct Reader {
235  template <class T>
236  size_t read(
237  typename std::enable_if<
239  T>::type& out,
240  folly::io::Cursor& cursor) {
241  using UT = typename std::underlying_type<U>::type;
242  out = static_cast<U>(cursor.readBE<UT>());
243  return sizeof(U);
244  }
245 
246  template <class T>
247  size_t read(
248  typename std::enable_if<
250  T>::type& out,
251  folly::io::Cursor& cursor) {
252  out = cursor.readBE<U>();
253  return sizeof(U);
254  }
255 };
256 
257 template <class T>
258 size_t read(T& out, folly::io::Cursor& cursor) {
259  return Reader<T>().template read<T>(out, cursor);
260 }
261 
262 template <class N, class T>
263 struct ReadVector {
264  size_t readVector(std::vector<T>& out, folly::io::Cursor& cursor) {
265  auto len = cursor.readBE<N>();
266  if (cursor.totalLength() < len) {
267  throw std::out_of_range("Not enough data");
268  }
269 
270  size_t consumed = 0;
271  while (consumed < len) {
272  out.push_back(T());
273  consumed += read(*out.rbegin(), cursor);
274  }
275  if (consumed != len) {
276  throw std::runtime_error("Invalid data length supplied");
277  }
278  return len + sizeof(N);
279  }
280 };
281 
282 template <class T>
283 struct ReadVector<bits24, T> {
284  size_t readVector(std::vector<T>& out, folly::io::Cursor& cursor) {
285  auto len = readBits24(cursor);
286  if (cursor.totalLength() < len) {
287  throw std::out_of_range("Not enough data");
288  }
289 
290  size_t consumed = 0;
291  while (consumed < len) {
292  out.push_back(T());
293  consumed += read(*out.rbegin(), cursor);
294  }
295  if (consumed != len) {
296  throw std::runtime_error("Invalid data length supplied");
297  }
298  return len + bits24::size;
299  }
300 };
301 
302 template <class N, class T>
303 size_t readVector(std::vector<T>& out, folly::io::Cursor& cursor) {
304  return ReadVector<N, T>().readVector(out, cursor);
305 }
306 
307 template <>
308 struct Reader<Random> {
309  template <class T>
310  size_t read(Random& out, folly::io::Cursor& cursor) {
311  cursor.pull(out.data(), out.size());
312  return out.size();
313  }
314 };
315 
316 template <>
317 struct Reader<Extension> {
318  template <class T>
319  size_t read(Extension& extension, folly::io::Cursor& cursor) {
320  extension.extension_type = static_cast<ExtensionType>(
322  auto len = readBuf<uint16_t>(extension.extension_data, cursor);
323  return sizeof(ExtensionType) + len;
324  }
325 };
326 
327 template <>
329  template <class T>
330  size_t read(CertificateEntry& entry, folly::io::Cursor& cursor) {
331  auto len = readBuf<bits24>(entry.cert_data, cursor);
332  len += readVector<uint16_t>(entry.extensions, cursor);
333  return len;
334  }
335 };
336 } // namespace detail
337 
338 template <>
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 }
355 
356 template <>
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);
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 }
369 
370 template <>
372  return folly::IOBuf::create(0);
373 }
374 
375 template <>
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 }
382 
383 template <>
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 }
391 
392 template <>
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 }
400 
401 template <>
403  return encode<const CertificateMsg&>(cert);
404 }
405 
406 template <>
408  return encode<CertificateMsg&>(cert);
409 }
410 
411 template <>
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 }
420 
421 template <>
424 }
425 
426 template <>
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 }
434 
435 template <>
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 }
443 
444 template <>
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 }
458 
459 template <>
462 }
463 
464 template <>
466  return encode<ClientHello&>(chlo);
467 }
468 
469 template <>
471  return std::move(fin.verify_data);
472 }
473 
474 template <>
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 }
487 
489  HkdfLabel&& label,
490  const std::string& hkdfLabelPrefix) {
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 }
500 
501 template <>
502 inline Buf encode<KeyUpdate>(KeyUpdate&& keyUpdate) {
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 }
508 
509 template <>
511  return std::move(hash.hash);
512 }
513 
514 template <class T>
515 Buf encodeHandshake(T&& handshakeMsg) {
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 }
525 
526 template <>
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 }
542 
543 template <>
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);
551  detail::readVector<uint16_t>(shlo.extensions, cursor);
552  return shlo;
553 }
554 
555 template <>
557  return EndOfEarlyData();
558 }
559 
560 template <>
563  detail::readVector<uint16_t>(ee.extensions, cursor);
564  return ee;
565 }
566 
567 template <>
570  detail::readBuf<uint8_t>(cr.certificate_request_context, cursor);
571  detail::readVector<uint16_t>(cr.extensions, cursor);
572  return cr;
573 }
574 
575 template <>
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 }
582 
583 template <>
586  detail::read(cc.algorithm, cursor);
588  detail::readBuf<detail::bits24>(cc.compressed_certificate_message, cursor);
589  return cc;
590 }
591 
592 template <>
594  CertificateVerify certVerify;
595  detail::read(certVerify.algorithm, cursor);
596  detail::readBuf<uint16_t>(certVerify.signature, cursor);
597  return certVerify;
598 }
599 
600 template <>
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 }
610 
611 template <>
612 inline Alert decode(folly::io::Cursor& cursor) {
613  Alert alert;
614  detail::read(alert.level, cursor);
615  detail::read(alert.description, cursor);
616  return alert;
617 }
618 
619 template <>
620 inline Finished decode<Finished>(std::unique_ptr<folly::IOBuf>&& buf) {
621  Finished fin;
622  fin.verify_data = std::move(buf);
623  return fin;
624 }
625 
626 template <>
628  KeyUpdate update;
629  detail::read(update.request_update, cursor);
630  return update;
631 }
632 
633 template <class T>
634 T decode(std::unique_ptr<folly::IOBuf>&& buf) {
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 }
644 
645 template <typename T>
646 std::string enumToHex(T enumValue) {
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 }
652 } // namespace fizz
std::vector< Extension > extensions
Definition: Types.h:228
#define T(v)
Definition: http_parser.c:233
Buf encodeHandshake(T &&handshakeMsg)
Definition: Types-inl.h:515
void writeVector(const std::vector< T > &data, folly::io::Appender &out)
Definition: Types-inl.h:149
Integral2 random(Integral1 low, Integral2 up)
KeyUpdateRequest request_update
Definition: Types.h:299
Buf encode< const ClientHello & >(const ClientHello &chlo)
Definition: Types-inl.h:445
size_t read(CertificateEntry &entry, folly::io::Cursor &cursor)
Definition: Types-inl.h:330
size_t readBuf(Buf &buf, folly::io::Cursor &cursor)
Definition: Types-inl.h:220
KeyUpdate decode< KeyUpdate >(folly::io::Cursor &cursor)
Definition: Types-inl.h:627
CertificateCompressionAlgorithm algorithm
Definition: Types.h:245
void write(const Random &random, folly::io::Appender &out)
Definition: Types-inl.h:173
Buf encode< ServerHello >(ServerHello &&shlo)
Definition: Types-inl.h:339
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
std::vector< Extension > extensions
Definition: Types.h:233
static constexpr Random HrrRandom
Definition: Types.h:211
Buf encode< HelloRetryRequest >(HelloRetryRequest &&shlo)
Definition: Types-inl.h:357
size_t readVector(std::vector< T > &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:303
Buf encode< Finished >(Finished &&fin)
Definition: Types-inl.h:470
static const std::string chlo
uint8_t legacy_compression_method
Definition: Types.h:204
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
Buf encode< CertificateRequest >(CertificateRequest &&cr)
Definition: Types-inl.h:384
AlertDescription description
Definition: Types.h:313
void clone(std::unique_ptr< folly::IOBuf > &buf, size_t len)
Definition: Cursor.h:456
Buf encodeHkdfLabel(HkdfLabel &&label, const std::string &hkdfLabelPrefix)
Definition: Types-inl.h:488
PskType type
TokenBindingMessage decode(folly::io::Cursor &cursor)
Definition: Types.cpp:132
Buf encode< CertificateVerify >(CertificateVerify &&certVerify)
Definition: Types-inl.h:427
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::string enumToHex(T enumValue)
Definition: Types-inl.h:646
Finished decode< Finished >(std::unique_ptr< folly::IOBuf > &&buf)
Definition: Types-inl.h:620
CipherSuite
Definition: Types.h:153
constexpr size_type size() const
Definition: Range.h:431
size_t readVector(std::vector< T > &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:284
uint32_t uncompressed_length
Definition: Types.h:246
void push(const uint8_t *buf, size_t len)
Definition: Cursor.h:755
size_t getBufSize(const Buf &buf)
Definition: Types-inl.h:33
Buf extension_data
Definition: Types.h:175
Buf legacy_session_id_echo
Definition: Types.h:202
Buf encode< EncryptedExtensions >(EncryptedExtensions &&extensions)
Definition: Types-inl.h:376
The non test part of the code is expected to have failures gtest_output_test_ cc
ProtocolVersion legacy_version
Definition: Types.h:188
void checkWithin24bits(const typename std::enable_if< std::is_integral< T >::value &&!std::is_signed< T >::value, T >::type &value)
Definition: Types-inl.h:92
void write< CertificateEntry >(const CertificateEntry &entry, folly::io::Appender &out)
Definition: Types-inl.h:203
std::vector< Extension > extensions
Definition: Types.h:289
Buf certificate_request_context
Definition: Types.h:238
void writeBuf< bits24 >(const Buf &buf, folly::io::Appender &out)
Definition: Types-inl.h:179
void pull(void *buf, size_t len)
Definition: Cursor.h:418
Random random
Definition: Types.h:189
ProtocolVersion
Definition: Types.h:24
Buf certificate_request_context
Definition: Types.h:253
Buf encode< NewSessionTicket >(NewSessionTicket &&nst)
Definition: Types-inl.h:475
std::vector< CertificateEntry > certificate_list
Definition: Types.h:239
int current
size_t readBuf< bits24 >(Buf &buf, folly::io::Cursor &cursor)
Definition: Types-inl.h:227
Buf legacy_session_id
Definition: Types.h:190
size_t read(Random &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:310
size_t getSize(const typename std::enable_if< (std::is_enum< T >::value||std::is_unsigned< T >::value)&&std::is_same< U, T >::value, T >::type &)
Definition: Types-inl.h:24
void writeBuf(const Buf &buf, folly::io::Appender &out)
size_t getSize(const CertificateEntry &entry)
Definition: Types-inl.h:58
Buf encode< ClientHello >(ClientHello &&chlo)
Definition: Types-inl.h:465
Buf encode< EndOfEarlyData >(EndOfEarlyData &&)
Definition: Types-inl.h:371
static T big(T x)
Definition: Bits.h:259
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
std::vector< Extension > extensions
Definition: Types.h:254
void writeBits24(T len, folly::io::Appender &out)
Definition: Types-inl.h:102
size_t getSize(const T &t)
Definition: Types-inl.h:43
Random random
Definition: Types.h:199
Definition: Actions.h:16
void writeVector(const std::vector< T > &data, folly::io::Appender &out)
Definition: Types-inl.h:118
std::vector< Extension > extensions
Definition: Types.h:193
size_t read(typename std::enable_if< std::is_enum< T >::value &&std::is_same< U, T >::value, T >::type &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:236
void write< Extension >(const Extension &extension, folly::io::Appender &out)
Definition: Types-inl.h:194
std::array< uint8_t, 32 > Random
Definition: Types.h:184
static const char *const value
Definition: Conv.cpp:50
std::vector< CipherSuite > cipher_suites
Definition: Types.h:191
void write(const typename std::enable_if< std::is_unsigned< T >::value &&std::is_same< U, T >::value, T >::type &in, folly::io::Appender &appender)
Definition: Types-inl.h:82
uint8_t level
Definition: Types.h:312
Buf verify_data
Definition: Types.h:278
Buf encode< ClientHello & >(ClientHello &chlo)
Definition: Types-inl.h:460
ExtensionType
Definition: Types.h:95
Buf encode< CompressedCertificate >(CompressedCertificate &&cc)
Definition: Types-inl.h:422
SignatureScheme algorithm
Definition: Types.h:273
Buf encode< CertificateMsg & >(CertificateMsg &cert)
Definition: Types-inl.h:402
uint32_t readBits24(folly::io::Cursor &cursor)
Definition: Types-inl.h:210
Buf encode< CertificateMsg >(CertificateMsg &&cert)
Definition: Types-inl.h:407
void writeVector(const std::vector< T > &data, folly::io::Appender &out)
Definition: Types-inl.h:134
std::vector< Extension > extensions
Definition: Types.h:205
Buf encode(TokenBindingMessage &&message)
Definition: Types.cpp:124
Buf encode< message_hash >(message_hash &&hash)
Definition: Types-inl.h:510
static const std::string nst
const char * string
Definition: Conv.cpp:212
ExtensionType extension_type
Definition: Types.h:174
std::unique_ptr< folly::IOBuf > Buf
Definition: Types.h:22
Buf encode< CompressedCertificate & >(CompressedCertificate &cc)
Definition: Types-inl.h:412
uint32_t ticket_lifetime
Definition: Types.h:284
Buf encode< KeyUpdate >(KeyUpdate &&keyUpdate)
Definition: Types-inl.h:502
size_t getSize(const Extension &proto)
Definition: Types-inl.h:50
HandshakeType
Definition: Types.h:62
Buf encode< const CertificateMsg & >(const CertificateMsg &cert)
Definition: Types-inl.h:393
size_t read(Extension &extension, folly::io::Cursor &cursor)
Definition: Types-inl.h:319
size_t getBufSize< bits24 >(const Buf &buf)
Definition: Types-inl.h:38
std::vector< uint8_t > legacy_compression_methods
Definition: Types.h:192
size_t read(typename std::enable_if< std::is_unsigned< T >::value &&std::is_same< U, T >::value, T >::type &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:247
Buf encode< Alert >(Alert &&alert)
Definition: Types-inl.h:436
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
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
static constexpr size_t size
Definition: Types-inl.h:18
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
ThreadPoolListHook * addr
size_t readVector(std::vector< T > &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:264
CipherSuite cipher_suite
Definition: Types.h:203
size_t totalLength() const
Definition: Cursor.h:126
ProtocolVersion legacy_version
Definition: Types.h:198
NewSessionTicket decode< NewSessionTicket >(folly::io::Cursor &cursor)
Definition: Types-inl.h:601
uint32_t ticket_age_add
Definition: Types.h:285
StringPiece label
void write(const typename std::enable_if< std::is_enum< T >::value &&std::is_same< U, T >::value, T >::type &in, folly::io::Appender &appender)
Definition: Types-inl.h:72
void writeBE(T value)
Definition: Cursor.h:744