diff options
author | Jeffrey Walton <noloader@gmail.com> | 2017-11-15 23:05:30 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2017-11-15 23:05:30 -0500 |
commit | 6f83a4fb7dfbbd1652524be36e3b3261ba13bc33 (patch) | |
tree | 9b086f115a89b685ecc2b0b7ab0d4ddfa057a1e4 /gcm.cpp | |
parent | c49b6d4d71ea94edbbf1e46478cfec66f20cd8ea (diff) | |
download | cryptopp-git-6f83a4fb7dfbbd1652524be36e3b3261ba13bc33.tar.gz |
Switch to intrinsic operation instead of casts for GCM SSE2 XOR's
Diffstat (limited to 'gcm.cpp')
-rw-r--r-- | gcm.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -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
@@ -102,13 +100,10 @@ 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)
|