/src/nss/fuzz/tls_client_config.cc
Line | Count | Source |
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. |
19 | 36.4k | ClientConfig::ClientConfig(const uint8_t* data, size_t len) { |
20 | 49.7M | for (size_t i = 0; i < len; i++) { |
21 | 49.6M | config_ ^= static_cast<uint64_t>(data[i]) << (8 * (i % 8)); |
22 | 49.6M | } |
23 | 36.4k | } |
24 | | |
25 | 19.2k | bool ClientConfig::FailCertificateAuthentication() { |
26 | 19.2k | return config_ & CONFIG_FAIL_CERT_AUTH; |
27 | 19.2k | } |
28 | | |
29 | 36.4k | bool ClientConfig::EnableExtendedMasterSecret() { |
30 | 36.4k | return config_ & CONFIG_ENABLE_EXTENDED_MS; |
31 | 36.4k | } |
32 | | |
33 | 36.4k | bool ClientConfig::RequireDhNamedGroups() { |
34 | 36.4k | return config_ & CONFIG_REQUIRE_DH_NAMED_GROUPS; |
35 | 36.4k | } |
36 | | |
37 | 36.4k | bool ClientConfig::EnableFalseStart() { |
38 | 36.4k | return config_ & CONFIG_ENABLE_FALSE_START; |
39 | 36.4k | } |
40 | | |
41 | 36.4k | bool ClientConfig::EnableDeflate() { return config_ & CONFIG_ENABLE_DEFLATE; } |
42 | | |
43 | 36.4k | bool ClientConfig::EnableCbcRandomIv() { |
44 | 36.4k | return config_ & CONFIG_ENABLE_CBC_RANDOM_IV; |
45 | 36.4k | } |
46 | | |
47 | 36.4k | bool ClientConfig::RequireSafeNegotiation() { |
48 | 36.4k | return config_ & CONFIG_REQUIRE_SAFE_NEGOTIATION; |
49 | 36.4k | } |
50 | | |
51 | 36.4k | bool ClientConfig::EnableCache() { return config_ & CONFIG_ENABLE_CACHE; } |