diff options
Diffstat (limited to 'src/lib/hash/comb4p')
-rw-r--r-- | src/lib/hash/comb4p/comb4p.cpp | 17 | ||||
-rw-r--r-- | src/lib/hash/comb4p/comb4p.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/hash/comb4p/comb4p.cpp b/src/lib/hash/comb4p/comb4p.cpp index 194c4613e..4cb08eb0b 100644 --- a/src/lib/hash/comb4p/comb4p.cpp +++ b/src/lib/hash/comb4p/comb4p.cpp @@ -5,12 +5,15 @@ * Botan is released under the Simplified BSD License (see license.txt) */ +#include <botan/internal/hash_utils.h> #include <botan/comb4p.h> #include <botan/internal/xor_buf.h> #include <stdexcept> namespace Botan { +BOTAN_REGISTER_NAMED_T(HashFunction, "Comb4P", Comb4P, Comb4P::make); + namespace { void comb4p_round(secure_vector<byte>& out, @@ -34,6 +37,20 @@ void comb4p_round(secure_vector<byte>& out, } +Comb4P* Comb4P::make(const Spec& spec) + { + if(spec.arg_count() == 2) + { + auto& hashes = Algo_Registry<HashFunction>::global_registry(); + std::unique_ptr<HashFunction> h1(hashes.make(spec.arg(0))); + std::unique_ptr<HashFunction> h2(hashes.make(spec.arg(1))); + + if(h1 && h2) + return new Comb4P(h1.release(), h2.release()); + } + return nullptr; + } + Comb4P::Comb4P(HashFunction* h1, HashFunction* h2) : m_hash1(h1), m_hash2(h2) { diff --git a/src/lib/hash/comb4p/comb4p.h b/src/lib/hash/comb4p/comb4p.h index ba745aefa..d2e9587c2 100644 --- a/src/lib/hash/comb4p/comb4p.h +++ b/src/lib/hash/comb4p/comb4p.h @@ -32,6 +32,8 @@ class BOTAN_DLL Comb4P : public HashFunction return m_hash1->output_length() + m_hash2->output_length(); } + static Comb4P* make(const Spec& spec); + HashFunction* clone() const { return new Comb4P(m_hash1->clone(), m_hash2->clone()); |