Fix ChaCha compiler crash for GCC 3.3
parent
2d06777747
commit
8838f78ec4
15
chacha.cpp
15
chacha.cpp
|
|
@ -10,13 +10,18 @@
|
|||
#include "misc.h"
|
||||
#include "cpu.h"
|
||||
|
||||
// Internal compiler error in GCC 3.3 and below
|
||||
#if defined(__GNUC__) && (__GNUC__ < 4)
|
||||
# undef CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#endif
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
extern void ChaCha_OperateKeystream_NEON(const word32 *state, const byte* input, byte *output, unsigned int rounds);
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
extern void ChaCha_OperateKeystream_SSE2(const word32 *state, const byte* input, byte *output, unsigned int rounds);
|
||||
#endif
|
||||
|
||||
|
|
@ -73,7 +78,7 @@ std::string ChaCha_Policy::AlgorithmProvider() const
|
|||
return "AVX2";
|
||||
else
|
||||
#endif
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
return "SSE2";
|
||||
else
|
||||
|
|
@ -140,7 +145,7 @@ unsigned int ChaCha_Policy::GetAlignment() const
|
|||
return 16;
|
||||
else
|
||||
#endif
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
return 16;
|
||||
else
|
||||
|
|
@ -160,7 +165,7 @@ unsigned int ChaCha_Policy::GetOptimalBlockSize() const
|
|||
return 8 * BYTES_PER_ITERATION;
|
||||
else
|
||||
#endif
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
return 4*BYTES_PER_ITERATION;
|
||||
else
|
||||
|
|
@ -211,7 +216,7 @@ void ChaCha_Policy::OperateKeystream(KeystreamOperation operation,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
if (HasSSE2())
|
||||
{
|
||||
while (iterationCount >= 4 && MultiBlockSafe(4))
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@
|
|||
#include "chacha.h"
|
||||
#include "misc.h"
|
||||
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
// Internal compiler error in GCC 3.3 and below
|
||||
#if defined(__GNUC__) && (__GNUC__ < 4)
|
||||
# undef CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
# include <xmmintrin.h>
|
||||
# include <emmintrin.h>
|
||||
#endif
|
||||
|
|
@ -161,7 +166,7 @@ inline uint32x4_t Add64(const uint32x4_t& a, const uint32x4_t& b)
|
|||
|
||||
// ***************************** SSE2 ***************************** //
|
||||
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
|
||||
template <unsigned int R>
|
||||
inline __m128i RotateLeft(const __m128i val)
|
||||
|
|
@ -199,7 +204,7 @@ inline __m128i RotateLeft<16>(const __m128i val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
|
||||
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
|
||||
// **************************** Altivec **************************** //
|
||||
|
||||
|
|
@ -556,7 +561,7 @@ void ChaCha_OperateKeystream_NEON(const word32 *state, const byte* input, byte *
|
|||
|
||||
// ***************************** SSE2 ***************************** //
|
||||
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
|
||||
|
||||
void ChaCha_OperateKeystream_SSE2(const word32 *state, const byte* input, byte *output, unsigned int rounds)
|
||||
{
|
||||
|
|
@ -820,7 +825,7 @@ void ChaCha_OperateKeystream_SSE2(const word32 *state, const byte* input, byte *
|
|||
_mm_storeu_si128(output_mm + 15, r3_3);
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
|
||||
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
|
||||
#if (CRYPTOPP_POWER7_AVAILABLE || CRYPTOPP_ALTIVEC_AVAILABLE)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue