aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/sha2_32/sha2_32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/hash/sha2_32/sha2_32.cpp')
-rw-r--r--src/lib/hash/sha2_32/sha2_32.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/hash/sha2_32/sha2_32.cpp b/src/lib/hash/sha2_32/sha2_32.cpp
index ab6903fa7..58977b617 100644
--- a/src/lib/hash/sha2_32/sha2_32.cpp
+++ b/src/lib/hash/sha2_32/sha2_32.cpp
@@ -11,6 +11,41 @@
namespace Botan {
+std::unique_ptr<HashFunction> SHA_224::copy_state() const
+ {
+ return std::unique_ptr<HashFunction>(new SHA_224(*this));
+ }
+
+std::unique_ptr<HashFunction> SHA_256::copy_state() const
+ {
+ return std::unique_ptr<HashFunction>(new SHA_256(*this));
+ }
+
+namespace {
+
+namespace SHA2_32 {
+
+/*
+* SHA-256 Rho Function
+*/
+inline uint32_t rho(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t rot3)
+ {
+ return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
+ rotate_right(X, rot3));
+ }
+
+/*
+* SHA-256 Sigma Function
+*/
+inline uint32_t sigma(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t shift)
+ {
+ return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
+ }
+
+}
+
+}
+
/*
* SHA-256 F1 Function
*