2 * Copyright 2016 Facebook, Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <folly/io/Cursor.h>
20 #include <folly/io/IOBuf.h>
22 #include <openssl/ssl.h>
23 #include <openssl/tls1.h>
29 // http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml
30 enum class TLSExtension : uint16_t {
32 MAX_FRAGMENT_LENGTH = 1,
33 CLIENT_CERTIFICATE_URL = 2,
41 SUPPORTED_GROUPS = 10,
42 EC_POINT_FORMATS = 11,
44 SIGNATURE_ALGORITHMS = 13,
47 APPLICATION_LAYER_PROTOCOL_NEGOTIATION = 16,
48 STATUS_REQUEST_V2 = 17,
49 SIGNED_CERTIFICATE_TIMESTAMP = 18,
50 CLIENT_CERTIFICATE_TYPE = 19,
51 SERVER_CERTIFICATE_TYPE = 20,
53 ENCRYPT_THEN_MAC = 22,
54 EXTENDED_MASTER_SECRET = 23,
56 // Facebook-specific, not IANA assigned yet
57 TLS_CACHED_INFO_FB = 60001,
58 // End Facebook-specific
59 RENEGOTIATION_INFO = 65281
62 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-18
63 enum class HashAlgorithm : uint8_t {
73 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-16
74 enum class SignatureAlgorithm : uint8_t {
81 struct ClientHelloInfo {
82 folly::IOBufQueue clientHelloBuf_;
83 uint8_t clientHelloMajorVersion_;
84 uint8_t clientHelloMinorVersion_;
85 std::vector<uint16_t> clientHelloCipherSuites_;
86 std::vector<uint8_t> clientHelloCompressionMethods_;
87 std::vector<TLSExtension> clientHelloExtensions_;
88 std::vector<std::pair<HashAlgorithm, SignatureAlgorithm>> clientHelloSigAlgs_;