aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-11-25 12:34:53 -0500
committerJack Lloyd <[email protected]>2016-11-25 12:34:53 -0500
commit3e0b4444a0723cf0bd1e1ba591292e112287ecfc (patch)
tree2d308c30eed117b261433bd5d2eef956d2b87af0 /src/lib/tls
parent73289331dde7d238c74436656234c284d2a177eb (diff)
Simplify TLS::Handshake_Hash::update
The lambda here wasn't really required.
Diffstat (limited to 'src/lib/tls')
-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();