1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #include "tls_client_config.h"
6 
7 const uint64_t CONFIG_FAIL_CERT_AUTH = 0x01;
8 const uint64_t CONFIG_ENABLE_EXTENDED_MS = 0x02;
9 const uint64_t CONFIG_REQUIRE_DH_NAMED_GROUPS = 0x04;
10 const uint64_t CONFIG_ENABLE_FALSE_START = 0x08;
11 const uint64_t CONFIG_ENABLE_DEFLATE = 0x10;
12 const uint64_t CONFIG_ENABLE_CBC_RANDOM_IV = 0x20;
13 const uint64_t CONFIG_REQUIRE_SAFE_NEGOTIATION = 0x40;
14 const uint64_t CONFIG_ENABLE_CACHE = 0x80;
15 
16 // XOR 64-bit chunks of data to build a bitmap of config options derived from
17 // the fuzzing input. This seems the only way to fuzz various options while
18 // still maintaining compatibility with BoringSSL or OpenSSL fuzzers.
ClientConfig(const uint8_t * data,size_t len)19 ClientConfig::ClientConfig(const uint8_t* data, size_t len) {
20   for (size_t i = 0; i < len; i++) {
21     config_ ^= static_cast<uint64_t>(data[i]) << (8 * (i % 8));
22   }
23 }
24 
FailCertificateAuthentication()25 bool ClientConfig::FailCertificateAuthentication() {
26   return config_ & CONFIG_FAIL_CERT_AUTH;
27 }
28 
EnableExtendedMasterSecret()29 bool ClientConfig::EnableExtendedMasterSecret() {
30   return config_ & CONFIG_ENABLE_EXTENDED_MS;
31 }
32 
RequireDhNamedGroups()33 bool ClientConfig::RequireDhNamedGroups() {
34   return config_ & CONFIG_REQUIRE_DH_NAMED_GROUPS;
35 }
36 
EnableFalseStart()37 bool ClientConfig::EnableFalseStart() {
38   return config_ & CONFIG_ENABLE_FALSE_START;
39 }
40 
EnableDeflate()41 bool ClientConfig::EnableDeflate() { return config_ & CONFIG_ENABLE_DEFLATE; }
42 
EnableCbcRandomIv()43 bool ClientConfig::EnableCbcRandomIv() {
44   return config_ & CONFIG_ENABLE_CBC_RANDOM_IV;
45 }
46 
RequireSafeNegotiation()47 bool ClientConfig::RequireSafeNegotiation() {
48   return config_ & CONFIG_REQUIRE_SAFE_NEGOTIATION;
49 }
50 
EnableCache()51 bool ClientConfig::EnableCache() { return config_ & CONFIG_ENABLE_CACHE; }
52