summaryrefslogtreecommitdiff
path: root/chacha_simd.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-01-03 13:37:53 -0500
committerJeffrey Walton <noloader@gmail.com>2019-01-03 13:37:53 -0500
commitb70bc4865f559db45adaabdc1aabc72c02e92de8 (patch)
tree43c942621b844a7a08ae7e64a91c0ff71a45292d /chacha_simd.cpp
parent8baa2f7a27b388e5416497c169b365f2b1e804d1 (diff)
downloadcryptopp-git-b70bc4865f559db45adaabdc1aabc72c02e92de8.tar.gz
Fix ChaCha NEON compile with MSVC compiler (GH #776)
Diffstat (limited to 'chacha_simd.cpp')
-rw-r--r--chacha_simd.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/chacha_simd.cpp b/chacha_simd.cpp
index 534445a6..b7d9c0a9 100644
--- a/chacha_simd.cpp
+++ b/chacha_simd.cpp
@@ -70,6 +70,15 @@ ANONYMOUS_NAMESPACE_BEGIN
// ***************************** NEON ***************************** //
+// Thanks to Peter Cordes, https://stackoverflow.com/q/54016821/608639
+#if (CRYPTOPP_ARM_NEON_AVAILABLE)
+# if defined(_MSC_VER)
+# define PACK32x4(w,x,y,z) { ((w) + (word64(x) << 32)), ((y) + (word64(z) << 32)) }
+# else
+# define PACK32x4(w,x,y,z) { (w), (x), (y), (z) }
+# endif
+#endif // Microsoft workaround
+
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
template <unsigned int R>
@@ -303,7 +312,9 @@ void ChaCha_OperateKeystream_NEON(const word32 *state, const byte* input, byte *
const uint32x4_t state3 = vld1q_u32(state + 3*4);
const uint32x4_t CTRS[3] = {
- {1,0,0,0}, {2,0,0,0}, {3,0,0,0}
+ PACK32x4(1,0,0,0),
+ PACK32x4(2,0,0,0),
+ PACK32x4(3,0,0,0)
};
uint32x4_t r0_0 = state0;