aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/par_hash
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-05-22 13:31:37 -0400
committerJack Lloyd <[email protected]>2017-05-22 13:31:37 -0400
commitf2f2fe7610f196cd4c5f51b5e588558762448d3c (patch)
tree70f0f84ea8c0659387e6726493a3065d05adcfe1 /src/lib/hash/par_hash
parent89e6af6b94de14a4325d6f761b1bf597b6eb450f (diff)
Add HashFunction::copy_state
See GH #1037
Diffstat (limited to 'src/lib/hash/par_hash')
-rw-r--r--src/lib/hash/par_hash/par_hash.cpp12
-rw-r--r--src/lib/hash/par_hash/par_hash.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/hash/par_hash/par_hash.cpp b/src/lib/hash/par_hash/par_hash.cpp
index 2a1ef7c9c..af43d6d97 100644
--- a/src/lib/hash/par_hash/par_hash.cpp
+++ b/src/lib/hash/par_hash/par_hash.cpp
@@ -56,6 +56,18 @@ HashFunction* Parallel::clone() const
return new Parallel(hash_copies);
}
+std::unique_ptr<HashFunction> Parallel::copy_state() const
+ {
+ std::vector<std::unique_ptr<HashFunction>> hash_clones;
+
+ for(const std::unique_ptr<HashFunction>& hash : m_hashes)
+ {
+ hash_clones.push_back(hash->copy_state());
+ }
+
+ return std::unique_ptr<HashFunction>(new Parallel(hash_clones));
+ }
+
void Parallel::clear()
{
for(auto&& hash : m_hashes)
diff --git a/src/lib/hash/par_hash/par_hash.h b/src/lib/hash/par_hash/par_hash.h
index cf6f49af4..85bf49208 100644
--- a/src/lib/hash/par_hash/par_hash.h
+++ b/src/lib/hash/par_hash/par_hash.h
@@ -22,6 +22,7 @@ class BOTAN_DLL Parallel final : public HashFunction
void clear() override;
std::string name() const override;
HashFunction* clone() const override;
+ std::unique_ptr<HashFunction> copy_state() const override;
size_t output_length() const override;