diff options
author | Jeffrey Walton <noloader@gmail.com> | 2018-11-02 18:34:46 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2018-11-02 18:34:46 -0400 |
commit | d2b64a4d638920a545dc412776829e695776dac2 (patch) | |
tree | c4ed00065d5bd5992a1d157321d59e7ad24bc289 /blake2.cpp | |
parent | 1fd8ac8b8b01c40e8cd9105c8edf4cdd0990d0b5 (diff) | |
download | cryptopp-git-d2b64a4d638920a545dc412776829e695776dac2.tar.gz |
Add BLAKE2b Power8 implementation (GH #731)
Diffstat (limited to 'blake2.cpp')
-rw-r--r-- | blake2.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -22,6 +22,11 @@ # undef CRYPTOPP_ARM_NEON_AVAILABLE
#endif
+// Disable POWER7 on PowerPC big-endian machines. BLAKE2s runs slower than C++.
+#if defined(__powerpc__) && defined(__BIG_ENDIAN__)
+# undef CRYPTOPP_POWER7_AVAILABLE
+#endif
+
ANONYMOUS_NAMESPACE_BEGIN
using CryptoPP::byte;
@@ -149,6 +154,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_POWER7_AVAILABLE
+extern void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2_State<word32, false>& state);
+#endif
+
#if CRYPTOPP_POWER8_AVAILABLE
extern void BLAKE2_Compress64_POWER8(const byte* input, BLAKE2_State<word64, true>& state);
#endif
@@ -356,6 +365,10 @@ std::string BLAKE2_Base<W, T_64bit>::AlgorithmProvider() const if (HasNEON())
return "NEON";
#endif
+#if (CRYPTOPP_POWER7_AVAILABLE)
+ if (HasPower7() && T_64bit == false)
+ return "Power7";
+#endif
#if (CRYPTOPP_POWER8_AVAILABLE)
if (HasPower8() && T_64bit == true)
return "Power8";
@@ -542,6 +555,12 @@ void BLAKE2_Base<word32, false>::Compress(const byte *input) return BLAKE2_Compress32_NEON(input, *m_state.data());
}
#endif
+#if CRYPTOPP_POWER7_AVAILABLE
+ if(HasPower7())
+ {
+ return BLAKE2_Compress32_POWER7(input, *m_state.data());
+ }
+#endif
return BLAKE2_Compress32_CXX(input, *m_state.data());
}
|