diff options
author | Jack Lloyd <[email protected]> | 2017-05-22 13:31:37 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-05-22 13:31:37 -0400 |
commit | f2f2fe7610f196cd4c5f51b5e588558762448d3c (patch) | |
tree | 70f0f84ea8c0659387e6726493a3065d05adcfe1 /src/lib/hash/checksum | |
parent | 89e6af6b94de14a4325d6f761b1bf597b6eb450f (diff) |
Add HashFunction::copy_state
See GH #1037
Diffstat (limited to 'src/lib/hash/checksum')
-rw-r--r-- | src/lib/hash/checksum/adler32/adler32.cpp | 5 | ||||
-rw-r--r-- | src/lib/hash/checksum/adler32/adler32.h | 1 | ||||
-rw-r--r-- | src/lib/hash/checksum/crc24/crc24.cpp | 5 | ||||
-rw-r--r-- | src/lib/hash/checksum/crc24/crc24.h | 1 | ||||
-rw-r--r-- | src/lib/hash/checksum/crc32/crc32.cpp | 5 | ||||
-rw-r--r-- | src/lib/hash/checksum/crc32/crc32.h | 1 |
6 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/hash/checksum/adler32/adler32.cpp b/src/lib/hash/checksum/adler32/adler32.cpp index b7f6356c4..329ba99a8 100644 --- a/src/lib/hash/checksum/adler32/adler32.cpp +++ b/src/lib/hash/checksum/adler32/adler32.cpp @@ -78,4 +78,9 @@ void Adler32::final_result(uint8_t output[]) clear(); } +std::unique_ptr<HashFunction> Adler32::copy_state() const + { + return std::unique_ptr<HashFunction>(new Adler32(*this)); + } + } diff --git a/src/lib/hash/checksum/adler32/adler32.h b/src/lib/hash/checksum/adler32/adler32.h index eaf57c656..98ba4f91a 100644 --- a/src/lib/hash/checksum/adler32/adler32.h +++ b/src/lib/hash/checksum/adler32/adler32.h @@ -21,6 +21,7 @@ class BOTAN_DLL Adler32 final : public HashFunction std::string name() const override { return "Adler32"; } size_t output_length() const override { return 4; } HashFunction* clone() const override { return new Adler32; } + std::unique_ptr<HashFunction> copy_state() const override; void clear() override { m_S1 = 1; m_S2 = 0; } diff --git a/src/lib/hash/checksum/crc24/crc24.cpp b/src/lib/hash/checksum/crc24/crc24.cpp index 923433d7e..bed456177 100644 --- a/src/lib/hash/checksum/crc24/crc24.cpp +++ b/src/lib/hash/checksum/crc24/crc24.cpp @@ -10,6 +10,11 @@ namespace Botan { +std::unique_ptr<HashFunction> CRC24::copy_state() const + { + return std::unique_ptr<HashFunction>(new CRC24(*this)); + } + /* * Update a CRC24 Checksum */ diff --git a/src/lib/hash/checksum/crc24/crc24.h b/src/lib/hash/checksum/crc24/crc24.h index 95977bc48..203611b8f 100644 --- a/src/lib/hash/checksum/crc24/crc24.h +++ b/src/lib/hash/checksum/crc24/crc24.h @@ -21,6 +21,7 @@ class BOTAN_DLL CRC24 final : public HashFunction std::string name() const override { return "CRC24"; } size_t output_length() const override { return 3; } HashFunction* clone() const override { return new CRC24; } + std::unique_ptr<HashFunction> copy_state() const override; void clear() override { m_crc = 0xB704CE; } diff --git a/src/lib/hash/checksum/crc32/crc32.cpp b/src/lib/hash/checksum/crc32/crc32.cpp index 1bbc35ac8..c69c8f80b 100644 --- a/src/lib/hash/checksum/crc32/crc32.cpp +++ b/src/lib/hash/checksum/crc32/crc32.cpp @@ -10,6 +10,11 @@ namespace Botan { +std::unique_ptr<HashFunction> CRC32::copy_state() const + { + return std::unique_ptr<HashFunction>(new CRC32(*this)); + } + /* * Update a CRC32 Checksum */ diff --git a/src/lib/hash/checksum/crc32/crc32.h b/src/lib/hash/checksum/crc32/crc32.h index fd9db1b3e..e1e266de3 100644 --- a/src/lib/hash/checksum/crc32/crc32.h +++ b/src/lib/hash/checksum/crc32/crc32.h @@ -21,6 +21,7 @@ class BOTAN_DLL CRC32 final : public HashFunction std::string name() const override { return "CRC32"; } size_t output_length() const override { return 4; } HashFunction* clone() const override { return new CRC32; } + std::unique_ptr<HashFunction> copy_state() const override; void clear() override { m_crc = 0xFFFFFFFF; } |