/src/nss/fuzz/targets/lib/tls/server_config.h
Line | Count | Source (jump to first uncovered line) |
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 file, |
3 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #ifndef TLS_SERVER_CONFIG_H_ |
6 | | #define TLS_SERVER_CONFIG_H_ |
7 | | |
8 | | #include <cstddef> |
9 | | #include <cstdint> |
10 | | #include <ostream> |
11 | | |
12 | | #include "prio.h" |
13 | | #include "sslt.h" |
14 | | |
15 | | #ifdef IS_DTLS_FUZZ |
16 | | #define SSL_VERSION_RANGE_MIN_VALID 0x0302 |
17 | | #else |
18 | 67.8k | #define SSL_VERSION_RANGE_MIN_VALID 0x0301 |
19 | | #endif |
20 | 67.8k | #define SSL_VERSION_RANGE_MAX_VALID 0x0304 |
21 | | |
22 | | namespace TlsServer { |
23 | | |
24 | | class Config { |
25 | | public: |
26 | | Config(const uint8_t* data, size_t len); |
27 | | |
28 | | void SetCallbacks(PRFileDesc* fd); |
29 | | void SetSocketOptions(PRFileDesc* fd); |
30 | | |
31 | 17.1k | SSLHashType PskHashType() { |
32 | 17.1k | if (config_ % 2) return ssl_hash_sha256; |
33 | | |
34 | 8.45k | return ssl_hash_sha384; |
35 | 17.1k | }; |
36 | 0 | SSLVersionRange SslVersionRange() { return ssl_version_range_; }; |
37 | | |
38 | | // NOTE: When adding more config options here, don't forget to print |
39 | | // them in the "<<"-overloaded operator. |
40 | 33.9k | bool EnableExtendedMasterSecret() { return config_ & (1 << 0); }; |
41 | 33.9k | bool RequestCertificate() { return config_ & (1 << 1); }; |
42 | 33.9k | bool RequireCertificate() { return config_ & (1 << 2); }; |
43 | 33.9k | bool EnableDeflate() { return config_ & (1 << 3); }; |
44 | 33.9k | bool EnableCbcRandomIv() { return config_ & (1 << 4); }; |
45 | 33.9k | bool RequireSafeNegotiation() { return config_ & (1 << 5); }; |
46 | 33.9k | bool NoCache() { return config_ & (1 << 6); }; |
47 | 33.9k | bool EnableGrease() { return config_ & (1 << 7); }; |
48 | 33.9k | bool SetCertificateCompressionAlgorithm() { return config_ & (1 << 8); }; |
49 | 33.9k | bool SetVersionRange() { return config_ & (1 << 9); }; |
50 | 33.9k | bool AddExternalPsk() { return config_ & (1 << 10); }; |
51 | 33.9k | bool EnableZeroRtt() { return config_ & (1 << 11); }; |
52 | 33.9k | bool EnableAlpn() { return config_ & (1 << 12); }; |
53 | 33.9k | bool EnableFallbackScsv() { return config_ & (1 << 13); }; |
54 | 33.9k | bool EnableSessionTickets() { return config_ & (1 << 14); }; |
55 | 33.9k | bool NoLocks() { return config_ & (1 << 15); }; |
56 | 16.6k | bool FailCertificateAuthentication() { return config_ & (1 << 16); } |
57 | 33.9k | bool EnableTls13BackendEch() { return config_ & (1 << 17); } |
58 | 33.9k | bool EnableDelegatedCredentials() { return config_ & (1 << 18); }; |
59 | 33.9k | bool EnableDtlsShortHeader() { return config_ & (1 << 19); }; |
60 | | |
61 | | private: |
62 | | uint32_t config_; |
63 | | SSLVersionRange ssl_version_range_; |
64 | | }; |
65 | | |
66 | | std::ostream& operator<<(std::ostream& out, Config& config); |
67 | | |
68 | | } // namespace TlsServer |
69 | | |
70 | | #endif // TLS_SERVER_CONFIG_H_ |