Switch to intrinsic operation instead of casts for GCM SSE2 XOR's
parent
c49b6d4d71
commit
6f83a4fb7d
|
|
@ -83,7 +83,7 @@ inline poly128_t VMULL_HIGH_P64(poly64x2_t a, poly64x2_t b)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64) && CRYPTOPP_ARM_PMULL_AVAILABLE
|
||||
#if CRYPTOPP_ARM_PMULL_AVAILABLE
|
||||
#if defined(__GNUC__)
|
||||
// Schneiders, Hovsmith and O'Rourke used this trick.
|
||||
// It results in much better code generation in production code
|
||||
|
|
|
|||
29
gcm.cpp
29
gcm.cpp
|
|
@ -67,7 +67,7 @@ void GCM_Base::GCTR::IncrementCounterBy256()
|
|||
IncrementCounterByOne(m_counterArray+BlockSize()-4, 3);
|
||||
}
|
||||
|
||||
inline static void Xor16(byte *a, const byte *b, const byte *c)
|
||||
static inline void Xor16(byte *a, const byte *b, const byte *c)
|
||||
{
|
||||
CRYPTOPP_ASSERT(IsAlignedOn(a,GetAlignmentOf<word64>()));
|
||||
CRYPTOPP_ASSERT(IsAlignedOn(b,GetAlignmentOf<word64>()));
|
||||
|
|
@ -77,19 +77,17 @@ inline static void Xor16(byte *a, const byte *b, const byte *c)
|
|||
}
|
||||
|
||||
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
|
||||
inline static void GCM_Xor16_SSE2(byte *a, const byte *b, const byte *c)
|
||||
static inline void GCM_Xor16_SSE2(byte *a, const byte *b, const byte *c)
|
||||
{
|
||||
// SunCC 5.14 crash (bewildering since asserts are not in effect in release builds)
|
||||
// Also see http://github.com/weidai11/cryptopp/issues/226 and http://github.com/weidai11/cryptopp/issues/284
|
||||
# if __SUNPRO_CC
|
||||
*M128_CAST(a) = _mm_xor_si128(*M128_CAST(b), *M128_CAST(c));
|
||||
# elif CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
CRYPTOPP_ASSERT(IsAlignedOn(a,GetAlignmentOf<__m128i>()));
|
||||
CRYPTOPP_ASSERT(IsAlignedOn(b,GetAlignmentOf<__m128i>()));
|
||||
CRYPTOPP_ASSERT(IsAlignedOn(c,GetAlignmentOf<__m128i>()));
|
||||
*M128_CAST(a) = _mm_xor_si128(*M128_CAST(b), *M128_CAST(c));
|
||||
# else
|
||||
asm ("movdqa %1, %%xmm0; pxor %2, %%xmm0; movdqa %%xmm0, %0;" : "=m" (a[0]) : "m"(b[0]), "m"(c[0]));
|
||||
// SunCC 5.14 crash. Also see http://github.com/weidai11/cryptopp/issues/226
|
||||
// and http://github.com/weidai11/cryptopp/issues/284
|
||||
# if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(__SUNPRO_CC)
|
||||
asm ("movdqa %1, %%xmm0; pxor %2, %%xmm0; movdqa %%xmm0, %0;"
|
||||
: "=m" (a[0]) : "m"(b[0]), "m"(c[0]));
|
||||
# else // CRYPTOPP_SSE2_INTRIN_AVAILABLE
|
||||
_mm_store_si128(M128_CAST(a), _mm_xor_si128(
|
||||
_mm_load_si128(CONST_M128_CAST(b)),
|
||||
_mm_load_si128(CONST_M128_CAST(c))));
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -101,14 +99,11 @@ const unsigned int s_cltableSizeInBlocks = 8;
|
|||
extern void GCM_ReverseHashBufferIfNeeded_CLMUL(byte *hashBuffer);
|
||||
#endif // CRYPTOPP_CLMUL_AVAILABLE
|
||||
|
||||
#if CRYPTOPP_ARM_PMULL_AVAILABLE
|
||||
extern void GCM_ReverseHashBufferIfNeeded_PMULL(byte *hashBuffer);
|
||||
#endif
|
||||
|
||||
#if CRYPTOPP_ARM_PMULL_AVAILABLE
|
||||
extern void GCM_SetKeyWithoutResync_PMULL(const byte *hashKey, byte *mulTable, unsigned int tableSize);
|
||||
extern size_t GCM_AuthenticateBlocks_PMULL(const byte *data, size_t len, const byte *mtable, byte *hbuffer);
|
||||
const unsigned int s_cltableSizeInBlocks = 8;
|
||||
extern void GCM_ReverseHashBufferIfNeeded_PMULL(byte *hashBuffer);
|
||||
#endif // CRYPTOPP_ARM_PMULL_AVAILABLE
|
||||
|
||||
void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms)
|
||||
|
|
|
|||
Loading…
Reference in New Issue