diff options
author | Jack Lloyd <[email protected]> | 2016-08-15 12:01:14 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-08-16 15:51:38 -0400 |
commit | b740f4dd6957d9beaf451854907916f1fb5f7a20 (patch) | |
tree | e6f6e51753b22e6f4159a392c6c1eae124e13bdc /src/lib/tls/tls_ciphersuite.h | |
parent | 25710f5375edb1af47699d128c04b4de0f2d0547 (diff) |
Clean up TLS ciphersuite handling
Stores ciphersuites in a sorted std::vector, then lookups are done
by binary search instead of a switch lookup.
The loop that explicitly gathered all the ciphersuites out of the switch
statement can then be removed, as can Ciphersuite::all_known_ciphersuite_ids
which only existed to make the scan loop faster by avoiding having to
call by_id on the entire 0x0000-0xFFFF range.
Precomputes the result of Ciphersuite::valid at construction time.
Diffstat (limited to 'src/lib/tls/tls_ciphersuite.h')
-rw-r--r-- | src/lib/tls/tls_ciphersuite.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/tls/tls_ciphersuite.h b/src/lib/tls/tls_ciphersuite.h index 1f646cc7e..199e126b1 100644 --- a/src/lib/tls/tls_ciphersuite.h +++ b/src/lib/tls/tls_ciphersuite.h @@ -29,13 +29,6 @@ class BOTAN_DLL Ciphersuite */ static Ciphersuite by_id(u16bit suite); - static std::vector<u16bit> all_known_ciphersuite_ids(); - - /* - * Returns the compiled in list of cipher suites. - */ - static const std::vector<Ciphersuite>& all_cipher_suites(); - /** * Returns true iff this suite is a known SCSV */ @@ -110,13 +103,17 @@ class BOTAN_DLL Ciphersuite /** * @return true if this is a valid/known ciphersuite */ - bool valid() const; + bool valid() const { return m_usable; } + + bool operator<(const Ciphersuite& o) const { return ciphersuite_code() < o.ciphersuite_code(); } + bool operator<(const u16bit c) const { return ciphersuite_code() < c; } Ciphersuite() {} private: - + bool is_usable() const; + Ciphersuite(u16bit ciphersuite_code, const char* iana_id, const char* sig_algo, @@ -140,6 +137,7 @@ class BOTAN_DLL Ciphersuite m_nonce_bytes_from_record(nonce_bytes_from_record), m_mac_keylen(mac_keylen) { + m_usable = is_usable(); } u16bit m_ciphersuite_code = 0; @@ -161,6 +159,8 @@ class BOTAN_DLL Ciphersuite size_t m_nonce_bytes_from_handshake = 0; size_t m_nonce_bytes_from_record = 0; size_t m_mac_keylen = 0; + + bool m_usable = false; }; } |