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_server_config.h"
6 
7 const uint64_t CONFIG_ENABLE_EXTENDED_MS = 0x01;
8 const uint64_t CONFIG_REQUEST_CERTIFICATE = 0x02;
9 const uint64_t CONFIG_REQUIRE_CERTIFICATE = 0x04;
10 const uint64_t CONFIG_ENABLE_DEFLATE = 0x08;
11 const uint64_t CONFIG_ENABLE_CBC_RANDOM_IV = 0x10;
12 const uint64_t CONFIG_REQUIRE_SAFE_NEGOTIATION = 0x20;
13 const uint64_t CONFIG_ENABLE_CACHE = 0x40;
14 
15 // XOR 64-bit chunks of data to build a bitmap of config options derived from
16 // the fuzzing input. This seems the only way to fuzz various options while
17 // still maintaining compatibility with BoringSSL or OpenSSL fuzzers.
ServerConfig(const uint8_t * data,size_t len)18 ServerConfig::ServerConfig(const uint8_t* data, size_t len) {
19   for (size_t i = 0; i < len; i++) {
20     config_ ^= static_cast<uint64_t>(data[i]) << (8 * (i % 8));
21   }
22 }
23 
EnableExtendedMasterSecret()24 bool ServerConfig::EnableExtendedMasterSecret() {
25   return config_ & CONFIG_ENABLE_EXTENDED_MS;
26 }
27 
RequestCertificate()28 bool ServerConfig::RequestCertificate() {
29   return config_ & CONFIG_REQUEST_CERTIFICATE;
30 }
31 
RequireCertificate()32 bool ServerConfig::RequireCertificate() {
33   return config_ & CONFIG_REQUIRE_CERTIFICATE;
34 }
35 
EnableDeflate()36 bool ServerConfig::EnableDeflate() { return config_ & CONFIG_ENABLE_DEFLATE; }
37 
EnableCbcRandomIv()38 bool ServerConfig::EnableCbcRandomIv() {
39   return config_ & CONFIG_ENABLE_CBC_RANDOM_IV;
40 }
41 
RequireSafeNegotiation()42 bool ServerConfig::RequireSafeNegotiation() {
43   return config_ & CONFIG_REQUIRE_SAFE_NEGOTIATION;
44 }
45 
EnableCache()46 bool ServerConfig::EnableCache() { return config_ & CONFIG_ENABLE_CACHE; }
47