summaryrefslogtreecommitdiffstats
path: root/comm/third_party/botan/src/lib/hash/comb4p/comb4p.h
diff options
context:
space:
mode:
Diffstat (limited to 'comm/third_party/botan/src/lib/hash/comb4p/comb4p.h')
-rw-r--r--comm/third_party/botan/src/lib/hash/comb4p/comb4p.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/comm/third_party/botan/src/lib/hash/comb4p/comb4p.h b/comm/third_party/botan/src/lib/hash/comb4p/comb4p.h
new file mode 100644
index 0000000000..518314c17d
--- /dev/null
+++ b/comm/third_party/botan/src/lib/hash/comb4p/comb4p.h
@@ -0,0 +1,61 @@
+/*
+* Comb4P hash combiner
+* (C) 2010 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_COMB4P_H_
+#define BOTAN_COMB4P_H_
+
+#include <botan/hash.h>
+
+BOTAN_FUTURE_INTERNAL_HEADER(comb4p.h)
+
+namespace Botan {
+
+/**
+* Combines two hash functions using a Feistel scheme. Described in
+* "On the Security of Hash Function Combiners", Anja Lehmann
+*/
+class BOTAN_PUBLIC_API(2,0) Comb4P final : public HashFunction
+ {
+ public:
+ /**
+ * @param h1 the first hash
+ * @param h2 the second hash
+ */
+ Comb4P(HashFunction* h1, HashFunction* h2);
+
+ size_t hash_block_size() const override;
+
+ size_t output_length() const override
+ {
+ return m_hash1->output_length() + m_hash2->output_length();
+ }
+
+ HashFunction* clone() const override
+ {
+ return new Comb4P(m_hash1->clone(), m_hash2->clone());
+ }
+
+ std::unique_ptr<HashFunction> copy_state() const override;
+
+ std::string name() const override
+ {
+ return "Comb4P(" + m_hash1->name() + "," + m_hash2->name() + ")";
+ }
+
+ void clear() override;
+ private:
+ Comb4P() = default;
+
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
+
+ std::unique_ptr<HashFunction> m_hash1, m_hash2;
+ };
+
+}
+
+#endif