TLSDefinitions.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2016-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <folly/io/Cursor.h>
  18. #include <folly/io/IOBuf.h>
  19. #include <map>
  20. #include <vector>
  21. namespace folly {
  22. namespace ssl {
  23. // http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml
  24. enum class TLSExtension : uint16_t {
  25. SERVER_NAME = 0,
  26. MAX_FRAGMENT_LENGTH = 1,
  27. CLIENT_CERTIFICATE_URL = 2,
  28. TRUSTED_CA_KEYS = 3,
  29. TRUNCATED_HMAC = 4,
  30. STATUS_REQUEST = 5,
  31. USER_MAPPING = 6,
  32. CLIENT_AUTHZ = 7,
  33. SERVER_AUTHZ = 8,
  34. CERT_TYPE = 9,
  35. SUPPORTED_GROUPS = 10,
  36. EC_POINT_FORMATS = 11,
  37. SRP = 12,
  38. SIGNATURE_ALGORITHMS = 13,
  39. USE_SRTP = 14,
  40. HEARTBEAT = 15,
  41. APPLICATION_LAYER_PROTOCOL_NEGOTIATION = 16,
  42. STATUS_REQUEST_V2 = 17,
  43. SIGNED_CERTIFICATE_TIMESTAMP = 18,
  44. CLIENT_CERTIFICATE_TYPE = 19,
  45. SERVER_CERTIFICATE_TYPE = 20,
  46. PADDING = 21,
  47. ENCRYPT_THEN_MAC = 22,
  48. EXTENDED_MASTER_SECRET = 23,
  49. SESSION_TICKET = 35,
  50. SUPPORTED_VERSIONS = 43,
  51. // Facebook-specific, not IANA assigned yet
  52. TLS_CACHED_INFO_FB = 60001,
  53. // End Facebook-specific
  54. RENEGOTIATION_INFO = 65281
  55. };
  56. // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-18
  57. enum class HashAlgorithm : uint8_t {
  58. NONE = 0,
  59. MD5 = 1,
  60. SHA1 = 2,
  61. SHA224 = 3,
  62. SHA256 = 4,
  63. SHA384 = 5,
  64. SHA512 = 6
  65. };
  66. // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-16
  67. enum class SignatureAlgorithm : uint8_t {
  68. ANONYMOUS = 0,
  69. RSA = 1,
  70. DSA = 2,
  71. ECDSA = 3
  72. };
  73. struct ClientHelloInfo {
  74. folly::IOBufQueue clientHelloBuf_;
  75. uint8_t clientHelloMajorVersion_;
  76. uint8_t clientHelloMinorVersion_;
  77. std::vector<uint16_t> clientHelloCipherSuites_;
  78. std::vector<uint8_t> clientHelloCompressionMethods_;
  79. std::vector<TLSExtension> clientHelloExtensions_;
  80. std::vector<std::pair<HashAlgorithm, SignatureAlgorithm>> clientHelloSigAlgs_;
  81. std::vector<uint16_t> clientHelloSupportedVersions_;
  82. };
  83. } // namespace ssl
  84. } // namespace folly