aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/tls/tls_handshake_hash.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lib/tls/tls_handshake_hash.cpp b/src/lib/tls/tls_handshake_hash.cpp
index 540f1de14..7bac87bc8 100644
--- a/src/lib/tls/tls_handshake_hash.cpp
+++ b/src/lib/tls/tls_handshake_hash.cpp
@@ -19,16 +19,12 @@ namespace TLS {
secure_vector<byte> Handshake_Hash::final(Protocol_Version version,
const std::string& mac_algo) const
{
- auto choose_hash = [=]() {
- if(!version.supports_ciphersuite_specific_prf())
- return "Parallel(MD5,SHA-160)";
+ std::string hash_algo = mac_algo;
+ if(!version.supports_ciphersuite_specific_prf())
+ hash_algo = "Parallel(MD5,SHA-160)";
+ else if(mac_algo == "MD5" || mac_algo == "SHA-1")
+ hash_algo = "SHA-256";
- if(mac_algo == "MD5" || mac_algo == "SHA-1")
- return "SHA-256";
- return mac_algo.c_str();
- };
-
- const std::string hash_algo = choose_hash();
std::unique_ptr<HashFunction> hash(HashFunction::create_or_throw(hash_algo));
hash->update(m_data);
return hash->final();