aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_handshake_hash.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-03-04 04:30:20 +0000
committerlloyd <[email protected]>2015-03-04 04:30:20 +0000
commit2591a2cd863696b91128ff4a8461bb96d497e7b4 (patch)
treeacb7a179a0790ec63c0c21ecb2ea9d7939e05248 /src/lib/tls/tls_handshake_hash.cpp
parentc794f78bd9b7eebc58c39fd00de90b26fb4cfb67 (diff)
Hide Algorithm_Factory and use the functions in lookup.h internally.
Fix two memory leaks (in TLS and modes) caused by calling get_foo and then cloning the result before saving it (leaking the original object), a holdover from the conversion between construction techniques in 1.11.14
Diffstat (limited to 'src/lib/tls/tls_handshake_hash.cpp')
-rw-r--r--src/lib/tls/tls_handshake_hash.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/tls/tls_handshake_hash.cpp b/src/lib/tls/tls_handshake_hash.cpp
index 76766c5fc..94c2774c5 100644
--- a/src/lib/tls/tls_handshake_hash.cpp
+++ b/src/lib/tls/tls_handshake_hash.cpp
@@ -7,7 +7,7 @@
#include <botan/internal/tls_handshake_hash.h>
#include <botan/tls_exceptn.h>
-#include <botan/internal/algo_registry.h>
+#include <botan/lookup.h>
#include <botan/hash.h>
namespace Botan {
@@ -20,18 +20,16 @@ namespace TLS {
secure_vector<byte> Handshake_Hash::final(Protocol_Version version,
const std::string& mac_algo) const
{
- std::unique_ptr<HashFunction> hash;
+ auto choose_hash = [=]() {
+ if(!version.supports_ciphersuite_specific_prf())
+ return "Parallel(MD5,SHA-160)";;
- if(version.supports_ciphersuite_specific_prf())
- {
if(mac_algo == "MD5" || mac_algo == "SHA-1")
- hash.reset(make_a<HashFunction>("SHA-256"));
- else
- hash.reset(make_a<HashFunction>(mac_algo));
- }
- else
- hash.reset(make_a<HashFunction>("Parallel(MD5,SHA-160)"));
+ return "SHA-256";
+ return mac_algo.c_str();
+ };
+ std::unique_ptr<HashFunction> hash(make_hash_function(choose_hash()));
hash->update(data);
return hash->final();
}