server_config.h (2388B)
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 #define SSL_VERSION_RANGE_MIN_VALID 0x0301 19 #endif 20 #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 SSLHashType PskHashType() { 32 if (config_ % 2) return ssl_hash_sha256; 33 34 return ssl_hash_sha384; 35 }; 36 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 bool EnableExtendedMasterSecret() { return config_ & (1 << 0); }; 41 bool RequestCertificate() { return config_ & (1 << 1); }; 42 bool RequireCertificate() { return config_ & (1 << 2); }; 43 bool EnableDeflate() { return config_ & (1 << 3); }; 44 bool EnableCbcRandomIv() { return config_ & (1 << 4); }; 45 bool RequireSafeNegotiation() { return config_ & (1 << 5); }; 46 bool NoCache() { return config_ & (1 << 6); }; 47 bool EnableGrease() { return config_ & (1 << 7); }; 48 bool SetCertificateCompressionAlgorithm() { return config_ & (1 << 8); }; 49 bool SetVersionRange() { return config_ & (1 << 9); }; 50 bool AddExternalPsk() { return config_ & (1 << 10); }; 51 bool EnableZeroRtt() { return config_ & (1 << 11); }; 52 bool EnableAlpn() { return config_ & (1 << 12); }; 53 bool EnableFallbackScsv() { return config_ & (1 << 13); }; 54 bool EnableSessionTickets() { return config_ & (1 << 14); }; 55 bool NoLocks() { return config_ & (1 << 15); }; 56 bool FailCertificateAuthentication() { return config_ & (1 << 16); } 57 bool EnableTls13BackendEch() { return config_ & (1 << 17); } 58 bool EnableDelegatedCredentials() { return config_ & (1 << 18); }; 59 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_