From c0a3a3046dbc39b05056f5539e68060c67a25f17 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 29 Jun 2012 14:55:56 +0000 Subject: Split TLS::Policy::allowed_hashes into allowed_signature_hashes and allowed_macs. This allows someone to turn on MD5 for message auth, which is a little sketchy but probably OK, without also (likely unintentionally) enabling MD5 for TLS v1.2 signatures, which would be a big problem. Prioritize RC4 over 3DES in default policy. Disable ECC curves smaller than 224 bits by default. More updates to the TLS policy documentation. --- src/tls/tls_policy.cpp | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'src/tls/tls_policy.cpp') diff --git a/src/tls/tls_policy.cpp b/src/tls/tls_policy.cpp index 87f8b5a14..c48ed274e 100644 --- a/src/tls/tls_policy.cpp +++ b/src/tls/tls_policy.cpp @@ -21,15 +21,15 @@ std::vector Policy::allowed_ciphers() const return std::vector({ "AES-256", "AES-128", - "3DES", "ARC4", + "3DES", //"Camellia-256", //"Camellia-128", //"SEED" }); } -std::vector Policy::allowed_hashes() const +std::vector Policy::allowed_signature_hashes() const { return std::vector({ "SHA-512", @@ -41,6 +41,16 @@ std::vector Policy::allowed_hashes() const }); } +std::vector Policy::allowed_macs() const + { + return std::vector({ + "SHA-384", + "SHA-256", + "SHA-1", + //"MD5", + }); + } + std::vector Policy::allowed_key_exchange_methods() const { return std::vector({ @@ -73,11 +83,11 @@ std::vector Policy::allowed_ecc_curves() const "secp256k1", "secp224r1", "secp224k1", - "secp192r1", - "secp192k1", - "secp160r2", - "secp160r1", - "secp160k1", + //"secp192r1", + //"secp192k1", + //"secp160r2", + //"secp160r1", + //"secp160k1", }); } @@ -136,10 +146,10 @@ class Ciphersuite_Preference_Ordering { public: Ciphersuite_Preference_Ordering(const std::vector& ciphers, - const std::vector& hashes, + const std::vector& macs, const std::vector& kex, const std::vector& sigs) : - m_ciphers(ciphers), m_hashes(hashes), m_kex(kex), m_sigs(sigs) {} + m_ciphers(ciphers), m_macs(macs), m_kex(kex), m_sigs(sigs) {} bool operator()(const Ciphersuite& a, const Ciphersuite& b) const { @@ -186,11 +196,11 @@ class Ciphersuite_Preference_Ordering if(a.mac_algo() != b.mac_algo()) { - for(size_t i = 0; i != m_hashes.size(); ++i) + for(size_t i = 0; i != m_macs.size(); ++i) { - if(a.mac_algo() == m_hashes[i]) + if(a.mac_algo() == m_macs[i]) return true; - if(b.mac_algo() == m_hashes[i]) + if(b.mac_algo() == m_macs[i]) return false; } } @@ -198,8 +208,7 @@ class Ciphersuite_Preference_Ordering return false; // equal (?!?) } private: - std::vector m_ciphers, m_hashes, m_kex, m_sigs; - + std::vector m_ciphers, m_macs, m_kex, m_sigs; }; } @@ -208,11 +217,11 @@ std::vector ciphersuite_list(const Policy& policy, bool have_srp) { const std::vector ciphers = policy.allowed_ciphers(); - const std::vector hashes = policy.allowed_hashes(); + const std::vector macs = policy.allowed_macs(); const std::vector kex = policy.allowed_key_exchange_methods(); const std::vector sigs = policy.allowed_signature_methods(); - Ciphersuite_Preference_Ordering order(ciphers, hashes, kex, sigs); + Ciphersuite_Preference_Ordering order(ciphers, macs, kex, sigs); std::set ciphersuites(order); @@ -227,7 +236,7 @@ std::vector ciphersuite_list(const Policy& policy, if(!value_exists(ciphers, suite.cipher_algo())) continue; // unsupported cipher - if(!value_exists(hashes, suite.mac_algo())) + if(!value_exists(macs, suite.mac_algo())) continue; // unsupported MAC algo if(!value_exists(sigs, suite.sig_algo())) -- cgit v1.2.3