diff options
author | Jack Lloyd <[email protected]> | 2016-08-31 12:58:58 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-08-31 12:58:58 -0400 |
commit | dfab07a7bc00dc00f98ab86c70d536306073f34f (patch) | |
tree | d3dbb140764f259c932171d6f229d033dee685ca /src/lib/tls/tls_ciphersuite.h | |
parent | e29024608fca1b811aa72a7aafd930a42740b968 (diff) | |
parent | 1b9cf39063194fe91dc8e5d78f73d7251c5d16fc (diff) |
Merge master into this branch, resolving conflicts with #457/#576
which recently landed on master.
Diffstat (limited to 'src/lib/tls/tls_ciphersuite.h')
-rw-r--r-- | src/lib/tls/tls_ciphersuite.h | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/src/lib/tls/tls_ciphersuite.h b/src/lib/tls/tls_ciphersuite.h index 47246ec11..6708e3ca6 100644 --- a/src/lib/tls/tls_ciphersuite.h +++ b/src/lib/tls/tls_ciphersuite.h @@ -29,21 +29,12 @@ class BOTAN_DLL Ciphersuite */ static Ciphersuite by_id(u16bit suite); - static std::vector<u16bit> all_known_ciphersuite_ids(); - /** * Returns true iff this suite is a known SCSV */ static bool is_scsv(u16bit suite); /** - * Lookup a ciphersuite by name - * @param name the name (eg TLS_RSA_WITH_RC4_128_SHA) - * @return ciphersuite object - */ - static Ciphersuite by_name(const std::string& name); - - /** * Generate a static list of all known ciphersuites and return it. * * @return list of all known ciphersuites @@ -54,7 +45,7 @@ class BOTAN_DLL Ciphersuite * Formats the ciphersuite back to an RFC-style ciphersuite string * @return RFC ciphersuite string identifier */ - std::string to_string() const; + std::string to_string() const { return m_iana_id; } /** * @return ciphersuite number @@ -79,26 +70,28 @@ class BOTAN_DLL Ciphersuite /** * @return key exchange algorithm used by this ciphersuite */ - const std::string& kex_algo() const { return m_kex_algo; } + std::string kex_algo() const { return m_kex_algo; } /** * @return signature algorithm used by this ciphersuite */ - const std::string& sig_algo() const { return m_sig_algo; } + std::string sig_algo() const { return m_sig_algo; } /** * @return symmetric cipher algorithm used by this ciphersuite */ - const std::string& cipher_algo() const { return m_cipher_algo; } + std::string cipher_algo() const { return m_cipher_algo; } /** * @return message authentication algorithm used by this ciphersuite */ - const std::string& mac_algo() const { return m_mac_algo; } + std::string mac_algo() const { return m_mac_algo; } - const std::string& prf_algo() const + std::string prf_algo() const { - return (!m_prf_algo.empty()) ? m_prf_algo : m_mac_algo; + if(m_prf_algo && *m_prf_algo) + return m_prf_algo; + return m_mac_algo; } /** @@ -115,13 +108,19 @@ 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, const char* kex_algo, const char* cipher_algo, @@ -130,21 +129,43 @@ class BOTAN_DLL Ciphersuite size_t nonce_bytes_from_record, const char* mac_algo, size_t mac_keylen, - const char* prf_algo = ""); + const char* prf_algo) : + m_ciphersuite_code(ciphersuite_code), + m_iana_id(iana_id), + m_sig_algo(sig_algo), + m_kex_algo(kex_algo), + m_prf_algo(prf_algo), + m_cipher_algo(cipher_algo), + m_mac_algo(mac_algo), + m_cipher_keylen(cipher_keylen), + m_nonce_bytes_from_handshake(nonce_bytes_from_handshake), + m_nonce_bytes_from_record(nonce_bytes_from_record), + m_mac_keylen(mac_keylen) + { + m_usable = is_usable(); + } u16bit m_ciphersuite_code = 0; - std::string m_sig_algo; - std::string m_kex_algo; - std::string m_prf_algo; + /* + All of these const char* strings are references to compile time + constants in tls_suite_info.cpp + */ + const char* m_iana_id; + + const char* m_sig_algo; + const char* m_kex_algo; + const char* m_prf_algo; + + const char* m_cipher_algo; + const char* m_mac_algo; - std::string m_cipher_algo; size_t m_cipher_keylen = 0; size_t m_nonce_bytes_from_handshake = 0; size_t m_nonce_bytes_from_record = 0; - - std::string m_mac_algo; size_t m_mac_keylen = 0; + + bool m_usable = false; }; } |