summaryrefslogtreecommitdiff
path: root/chacha_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 /chacha_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 'chacha_simd.cpp')
-rw-r--r--chacha_simd.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/chacha_simd.cpp b/chacha_simd.cpp
index 9a0bd6c3..0945c597 100644
--- a/chacha_simd.cpp
+++ b/chacha_simd.cpp
@@ -822,9 +822,12 @@ void ChaCha_OperateKeystream_SSE2(const word32 *state, const byte* input, byte *
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
-#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+#if (CRYPTOPP_POWER7_AVAILABLE || CRYPTOPP_ALTIVEC_AVAILABLE)
-void ChaCha_OperateKeystream_POWER7(const word32 *state, const byte* input, byte *output, unsigned int rounds)
+// ChaCha_OperateKeystream_CORE will use either POWER7 or ALTIVEC,
+// depending on the flags used to compile this source file. The
+// abstractions are handled in VecLoad, VecStore and friends.
+inline void ChaCha_OperateKeystream_CORE(const word32 *state, const byte* input, byte *output, unsigned int rounds)
{
const uint32x4_p state0 = VecLoad(state + 0*4);
const uint32x4_p state1 = VecLoad(state + 1*4);
@@ -1086,6 +1089,22 @@ void ChaCha_OperateKeystream_POWER7(const word32 *state, const byte* input, byte
VecStore32LE(output + 15*16, r3_3);
}
-#endif // CRYPTOPP_ALTIVEC_AVAILABLE
+#endif // CRYPTOPP_POWER7_AVAILABLE || CRYPTOPP_ALTIVEC_AVAILABLE
+
+#if (CRYPTOPP_POWER7_AVAILABLE)
+
+void ChaCha_OperateKeystream_POWER7(const word32 *state, const byte* input, byte *output, unsigned int rounds)
+{
+ ChaCha_OperateKeystream_CORE(state, input, output, rounds);
+}
+
+#elif (CRYPTOPP_ALTIVEC_AVAILABLE)
+
+void ChaCha_OperateKeystream_ALTIVEC(const word32 *state, const byte* input, byte *output, unsigned int rounds)
+{
+ ChaCha_OperateKeystream_CORE(state, input, output, rounds);
+}
+
+#endif
NAMESPACE_END