summaryrefslogtreecommitdiff
path: root/blake2s_simd.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-11-18 14:43:48 -0500
committerJeffrey Walton <noloader@gmail.com>2018-11-18 14:43:48 -0500
commit2e68e95a928a921db1cb97d4433f6a4ff09fcac8 (patch)
treef627dc6c55c9b393d9b1eb72bab46d3630f74235 /blake2s_simd.cpp
parente28b2e0f02dfdbd4794202d5829e3bf4afe63826 (diff)
downloadcryptopp-git-2e68e95a928a921db1cb97d4433f6a4ff09fcac8.tar.gz
Add BLAKE2s and ChaCha CORE SIMD function (GH #656)
The CORE function provides the implementation for ChaCha_OperateKeystream_ALTIVEC, ChaCha_OperateKeystream_POWER7, BLAKE2_Compress32_ALTIVEC and BLAKE2_Compress32_POWER7. Depending on the options used to compile the source files, either POWER7 or ALTIVEC will be used. This is needed to support the "new toolchain, ancient hardware" use case.
Diffstat (limited to 'blake2s_simd.cpp')
-rw-r--r--blake2s_simd.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/blake2s_simd.cpp b/blake2s_simd.cpp
index 1456ad23..1d756f9e 100644
--- a/blake2s_simd.cpp
+++ b/blake2s_simd.cpp
@@ -681,7 +681,7 @@ void BLAKE2_Compress32_NEON(const byte* input, BLAKE2s_State& state)
}
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
-#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+#if (CRYPTOPP_POWER7_AVAILABLE || CRYPTOPP_ALTIVEC_AVAILABLE)
inline uint32x4_p VecLoad32(const void* p)
{
@@ -847,7 +847,7 @@ uint32x4_p VectorSet32<3,1,3,1>(const uint32x4_p a, const uint32x4_p b,
return VecPermute(a, c, mask);
}
-void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2s_State& state)
+void BLAKE2_Compress32_CORE(const byte* input, BLAKE2s_State& state)
{
# define m1 m0
# define m2 m0
@@ -994,6 +994,22 @@ void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2s_State& state)
VecStore32LE(&state.h[0], VecXor(ff0, VecXor(row1, row3)));
VecStore32LE(&state.h[4], VecXor(ff1, VecXor(row2, row4)));
}
-#endif // CRYPTOPP_ALTIVEC_AVAILABLE
+#endif // CRYPTOPP_POWER7_AVAILABLE || CRYPTOPP_ALTIVEC_AVAILABLE
+
+#if (CRYPTOPP_POWER7_AVAILABLE)
+
+void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2s_State& state)
+{
+ BLAKE2_Compress32_CORE(input, state);
+}
+
+#elif (CRYPTOPP_ALTIVEC_AVAILABLE)
+
+void BLAKE2_Compress32_ALTIVEC(const byte* input, BLAKE2s_State& state)
+{
+ BLAKE2_Compress32_CORE(input, state);
+}
+
+#endif
NAMESPACE_END