aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/comb4p/comb4p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/hash/comb4p/comb4p.cpp')
-rw-r--r--src/lib/hash/comb4p/comb4p.cpp17
1 files changed, 17 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)
{