mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Fix ChaCha compile on ARM and MIPS
This commit is contained in:
parent
6a5d2ab03d
commit
d230999b40
@ -17,7 +17,7 @@
|
||||
#include "chacha.h"
|
||||
#include "misc.h"
|
||||
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
# include <xmmintrin.h>
|
||||
# include <emmintrin.h>
|
||||
#endif
|
||||
@ -38,7 +38,7 @@ extern const char CHACHA_SIMD_FNAME[] = __FILE__;
|
||||
|
||||
ANONYMOUS_NAMESPACE_BEGIN
|
||||
|
||||
#if defined(CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
|
||||
template <unsigned int R>
|
||||
inline __m128i RotateLeft(const __m128i val)
|
||||
@ -46,13 +46,13 @@ inline __m128i RotateLeft(const __m128i val)
|
||||
return _mm_or_si128(_mm_slli_epi32(val, R), _mm_srli_epi32(val, 32-R));
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#endif // (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
|
||||
ANONYMOUS_NAMESPACE_END
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
#if defined(CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
|
||||
void ChaCha_OperateKeystream_SSE2(const word32 *state, byte *message, unsigned int rounds)
|
||||
{
|
||||
@ -283,6 +283,6 @@ void ChaCha_OperateKeystream_SSE2(const word32 *state, byte *message, unsigned i
|
||||
_mm_storeu_si128(message_mm + 15, r3_3);
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#endif // (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
|
||||
NAMESPACE_END
|
||||
|
14
chacha.cpp
14
chacha.cpp
@ -11,10 +11,14 @@
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
#if defined(CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
extern void ChaCha_OperateKeystream_SSE2(const word32 *state, byte *message, unsigned int rounds);
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
extern void ChaCha_OperateKeystream_NEON(const word32 *state, byte *message, unsigned int rounds);
|
||||
#endif
|
||||
|
||||
#define CHACHA_QUARTER_ROUND(a,b,c,d) \
|
||||
a += b; d ^= a; d = rotlConstant<16,word32>(d); \
|
||||
c += d; b ^= c; b = rotlConstant<12,word32>(b); \
|
||||
@ -30,7 +34,7 @@ void ChaCha_TestInstantiations()
|
||||
|
||||
std::string ChaCha_Policy::AlgorithmProvider() const
|
||||
{
|
||||
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
return "SSE2";
|
||||
#endif
|
||||
@ -77,7 +81,7 @@ void ChaCha_Policy::SeekToIteration(lword iterationCount)
|
||||
|
||||
unsigned int ChaCha_Policy::GetAlignment() const
|
||||
{
|
||||
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
return 16;
|
||||
else
|
||||
@ -87,7 +91,7 @@ unsigned int ChaCha_Policy::GetAlignment() const
|
||||
|
||||
unsigned int ChaCha_Policy::GetOptimalBlockSize() const
|
||||
{
|
||||
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
return 4*BYTES_PER_ITERATION;
|
||||
else
|
||||
@ -98,7 +102,7 @@ unsigned int ChaCha_Policy::GetOptimalBlockSize() const
|
||||
void ChaCha_Policy::OperateKeystream(KeystreamOperation operation,
|
||||
byte *output, const byte *input, size_t iterationCount)
|
||||
{
|
||||
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
{
|
||||
while (iterationCount >= 4)
|
||||
|
3
chacha.h
3
chacha.h
@ -37,11 +37,8 @@ protected:
|
||||
void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
|
||||
bool CipherIsRandomAccess() const {return true;}
|
||||
void SeekToIteration(lword iterationCount);
|
||||
|
||||
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
|
||||
unsigned int GetAlignment() const;
|
||||
unsigned int GetOptimalBlockSize() const;
|
||||
#endif
|
||||
|
||||
std::string AlgorithmProvider() const;
|
||||
|
||||
|
4
config.h
4
config.h
@ -496,7 +496,7 @@ NAMESPACE_END
|
||||
#define CRYPTOPP_SSE2_ASM_AVAILABLE 1
|
||||
#endif
|
||||
|
||||
#if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || defined(__SSSE3__))
|
||||
#if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || CRYPTOPP_GCC_VERSION >= 40300 || defined(__SSSE3__))
|
||||
#define CRYPTOPP_SSSE3_ASM_AVAILABLE 1
|
||||
#endif
|
||||
#endif
|
||||
@ -510,7 +510,7 @@ NAMESPACE_END
|
||||
#endif
|
||||
|
||||
// 32-bit SunCC does not enable SSE2 by default.
|
||||
#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || defined(__SSE2__))
|
||||
#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
|
||||
#define CRYPTOPP_SSE2_INTRIN_AVAILABLE 1
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user