Skip to content

Commit

Permalink
Fix ChaCha NEON compile with MSVC compiler (GH #776)
Browse files Browse the repository at this point in the history
  • Loading branch information
noloader committed Jan 3, 2019
1 parent 8baa2f7 commit b70bc48
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion chacha_simd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b70bc48

Please sign in to comment.