summaryrefslogtreecommitdiff
path: root/blake2.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-10-30 06:20:31 -0400
committerJeffrey Walton <noloader@gmail.com>2018-10-30 06:20:31 -0400
commit659c0c113c9b35b3001a6a863f45d859443a7c82 (patch)
tree0eadf142d77899e9089df0c715f508099b33e5a4 /blake2.cpp
parent81db4ea5e39bbc45e2a7d0f3fabbbd25cd3d33ba (diff)
downloadcryptopp-git-659c0c113c9b35b3001a6a863f45d859443a7c82.tar.gz
Add BLAKE2b Power8 implementation (GH #729)
Diffstat (limited to 'blake2.cpp')
-rw-r--r--blake2.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/blake2.cpp b/blake2.cpp
index d400af1f..726a0bf8 100644
--- a/blake2.cpp
+++ b/blake2.cpp
@@ -14,6 +14,7 @@
// Do so in both blake2.cpp and blake2-simd.cpp.
// #undef CRYPTOPP_SSE41_AVAILABLE
// #undef CRYPTOPP_ARM_NEON_AVAILABLE
+// #undef CRYPTOPP_POWER8_AVAILABLE
// Disable NEON/ASIMD for Cortex-A53 and A57. The shifts are too slow and C/C++ is about
// 3 cpb faster than NEON/ASIMD. Also see http://github.com/weidai11/cryptopp/issues/367.
@@ -148,6 +149,10 @@ extern void BLAKE2_Compress32_NEON(const byte* input, BLAKE2_State<word32, false
extern void BLAKE2_Compress64_NEON(const byte* input, BLAKE2_State<word64, true>& state);
#endif
+#if CRYPTOPP_POWER8_AVAILABLE
+extern void BLAKE2_Compress64_POWER8(const byte* input, BLAKE2_State<word64, true>& state);
+#endif
+
BLAKE2_ParameterBlock<false>::BLAKE2_ParameterBlock(size_t digestLen, size_t keyLen,
const byte* saltStr, size_t saltLen,
const byte* personalizationStr, size_t personalizationLen)
@@ -340,7 +345,8 @@ void BLAKE2_Base<word64, true>::UncheckedSetKey(const byte *key, unsigned int le
}
}
-std::string BLAKE2_Base_AlgorithmProvider()
+template <class W, bool T_64bit>
+std::string BLAKE2_Base<W, T_64bit>::AlgorithmProvider() const
{
#if defined(CRYPTOPP_SSE41_AVAILABLE)
if (HasSSE41())
@@ -350,16 +356,14 @@ std::string BLAKE2_Base_AlgorithmProvider()
if (HasNEON())
return "NEON";
#endif
+#if (CRYPTOPP_POWER8_AVAILABLE)
+ if (HasPower8() && T_64bit == true)
+ return "Power8";
+#endif
return "C++";
}
template <class W, bool T_64bit>
-std::string BLAKE2_Base<W, T_64bit>::AlgorithmProvider() const
-{
- return BLAKE2_Base_AlgorithmProvider();
-}
-
-template <class W, bool T_64bit>
BLAKE2_Base<W, T_64bit>::BLAKE2_Base() : m_state(1), m_block(1), m_digestSize(DIGESTSIZE), m_treeMode(false)
{
UncheckedSetKey(NULLPTR, 0, g_nullNameValuePairs);
@@ -514,6 +518,12 @@ void BLAKE2_Base<word64, true>::Compress(const byte *input)
return BLAKE2_Compress64_NEON(input, *m_state.data());
}
#endif
+#if CRYPTOPP_POWER8_AVAILABLE
+ if(HasPower8())
+ {
+ return BLAKE2_Compress64_POWER8(input, *m_state.data());
+ }
+#endif
return BLAKE2_Compress64_CXX(input, *m_state.data());
}