summaryrefslogtreecommitdiff
path: root/sha.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-07-06 09:23:37 -0400
committerGitHub <noreply@github.com>2018-07-06 09:23:37 -0400
commitb74a6f444568e59a7766d1e286f82d2ce3086dcd (patch)
tree97937fe23f742f6c352f39e206b7ce7d774ba358 /sha.cpp
parent6d9047b444731175e6ea9a447a3f0002685804be (diff)
downloadcryptopp-git-b74a6f444568e59a7766d1e286f82d2ce3086dcd.tar.gz
Add algorithm provider member function to Algorithm class
Diffstat (limited to 'sha.cpp')
-rw-r--r--sha.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/sha.cpp b/sha.cpp
index 34bb4b7a..b0847fc3 100644
--- a/sha.cpp
+++ b/sha.cpp
@@ -151,6 +151,23 @@ ANONYMOUS_NAMESPACE_END
// end of Steve Reid's code //
//////////////////////////////
+std::string SHA1::AlgorithmProvider() const
+{
+#if CRYPTOPP_SHANI_AVAILABLE
+ if (HasSHA())
+ return "SHANI";
+#endif
+#if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+ if (HasSSE2())
+ return "SSE2";
+#endif
+#if CRYPTOPP_ARM_SHA_AVAILABLE
+ if (HasSHA1())
+ return "ARMv8";
+#endif
+ return "C++";
+}
+
void SHA1::InitState(HashWordType *state)
{
state[0] = 0x67452301;
@@ -320,6 +337,32 @@ void SHA256_HashBlock_CXX(word32 *state, const word32 *data)
ANONYMOUS_NAMESPACE_END
+std::string SHA256_AlgorithmProvider()
+{
+#if CRYPTOPP_SHANI_AVAILABLE
+ if (HasSHA())
+ return "SHANI";
+#endif
+#if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+ if (HasSSE2())
+ return "SSE2";
+#endif
+#if CRYPTOPP_ARM_SHA_AVAILABLE
+ if (HasSHA2())
+ return "ARMv8";
+#endif
+#if (CRYPTOPP_POWER8_SHA_AVAILABLE)
+ if (HasSHA256())
+ return "Power8";
+#endif
+ return "C++";
+}
+
+std::string SHA224::AlgorithmProvider() const
+{
+ return SHA256_AlgorithmProvider();
+}
+
void SHA224::InitState(HashWordType *state)
{
static const word32 s[8] = {0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4};
@@ -668,6 +711,11 @@ void CRYPTOPP_FASTCALL SHA256_HashMultipleBlocks_SSE2(word32 *state, const word3
}
#endif
+std::string SHA256::AlgorithmProvider() const
+{
+ return SHA256_AlgorithmProvider();
+}
+
void SHA256::Transform(word32 *state, const word32 *data)
{
CRYPTOPP_ASSERT(state);
@@ -812,6 +860,29 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length)
// *************************************************************
+std::string SHA512_AlgorithmProvider()
+{
+#if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+ if (HasSSE2())
+ return "SSE2";
+#endif
+#if (CRYPTOPP_POWER8_SHA_AVAILABLE)
+ if (HasSHA512())
+ return "Power8";
+#endif
+ return "C++";
+}
+
+std::string SHA384::AlgorithmProvider() const
+{
+ return SHA512_AlgorithmProvider();
+}
+
+std::string SHA512::AlgorithmProvider() const
+{
+ return SHA512_AlgorithmProvider();
+}
+
void SHA384::InitState(HashWordType *state)
{
const word64 s[8] = {