tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

client_config.h (2776B)


      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_CLIENT_CONFIG_H_
      6 #define TLS_CLIENT_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 TlsClient {
     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 FailCertificateAuthentication() { return config_ & (1 << 0); };
     41  bool EnableExtendedMasterSecret() { return config_ & (1 << 1); };
     42  bool RequireDhNamedGroups() { return config_ & (1 << 2); };
     43  bool EnableFalseStart() { return config_ & (1 << 3); };
     44  bool EnableDeflate() { return config_ & (1 << 4); };
     45  bool CbcRandomIv() { return config_ & (1 << 5); };
     46  bool RequireSafeNegotiation() { return config_ & (1 << 6); };
     47  bool NoCache() { return config_ & (1 << 7); };
     48  bool EnableGrease() { return config_ & (1 << 8); };
     49  bool EnableCHExtensionPermutation() { return config_ & (1 << 9); };
     50  bool SetCertificateCompressionAlgorithm() { return config_ & (1 << 10); };
     51  bool SetClientEchConfigs() { return config_ & (1 << 11); };
     52  bool SetVersionRange() { return config_ & (1 << 12); };
     53  bool AddExternalPsk() { return config_ & (1 << 13); };
     54  bool EnablePostHandshakeAuth() { return config_ & (1 << 14); };
     55  bool EnableZeroRtt() { return config_ & (1 << 15); };
     56  bool EnableAlpn() { return config_ & (1 << 16); };
     57  bool EnableFallbackScsv() { return config_ & (1 << 17); };
     58  bool EnableOcspStapling() { return config_ & (1 << 18); };
     59  bool EnableSessionTickets() { return config_ & (1 << 19); };
     60  bool EnableTls13CompatMode() { return config_ & (1 << 20); };
     61  bool NoLocks() { return config_ & (1 << 21); };
     62  bool EnableTls13GreaseEch() { return config_ & (1 << 22); };
     63  bool SetDtls13VersionWorkaround() { return config_ & (1 << 23); };
     64  bool EnableDelegatedCredentials() { return config_ & (1 << 24); };
     65  bool EnableDtlsShortHeader() { return config_ & (1 << 25); };
     66 
     67 private:
     68  uint32_t config_;
     69  SSLVersionRange ssl_version_range_;
     70 };
     71 
     72 std::ostream& operator<<(std::ostream& out, Config& config);
     73 
     74 }  // namespace TlsClient
     75 
     76 #endif  // TLS_CLIENT_CONFIG_H_