summaryrefslogtreecommitdiff
path: root/gcm.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-13 11:33:45 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-13 11:33:45 +0000
commit0e95a815a4bf8a4b1437e70fac09aa664cdbb55b (patch)
tree15f2d49edd13484a24d4cc9e3f72c1bd33113737 /gcm.cpp
parentb1d5c9a600e07a434b21353afe86374940e95bc8 (diff)
downloadcryptopp-0e95a815a4bf8a4b1437e70fac09aa664cdbb55b.tar.gz
speed up GCM key setup
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@452 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'gcm.cpp')
-rw-r--r--gcm.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcm.cpp b/gcm.cpp
index 75abe12..4d20011 100644
--- a/gcm.cpp
+++ b/gcm.cpp
@@ -49,10 +49,14 @@ void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *
}
#endif
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
inline static void SSE2_Xor16(byte *a, const byte *b, const byte *c)
{
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
*(__m128i *)a = _mm_xor_si128(*(__m128i *)b, *(__m128i *)c);
+#else
+ asm ("movdqa %1, %%xmm0; pxor %2, %%xmm0; movdqa %%xmm0, %0;" : "=m" (a[0]) : "m"(b[0]), "m"(c[0]));
+#endif
}
#endif
@@ -103,7 +107,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const
for (i=0; i<16; i++)
{
memset(table+i*256*16, 0, 16);
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
if (HasSSE2())
for (j=2; j<=0x80; j*=2)
for (k=1; k<j; k++)
@@ -149,7 +153,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const
{
memset(table+i*256, 0, 16);
memset(table+1024+i*256, 0, 16);
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
if (HasSSE2())
for (j=2; j<=8; j*=2)
for (k=1; k<j; k++)