summaryrefslogtreecommitdiff
path: root/gcm.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-11-16 02:38:53 -0500
committerJeffrey Walton <noloader@gmail.com>2017-11-16 02:38:53 -0500
commit8b52a03d0873bf3f252c58c76df1e4167fc33fa6 (patch)
treeea88ce75a34bdf52450e0eb184408af8b8edc084 /gcm.cpp
parent6f83a4fb7dfbbd1652524be36e3b3261ba13bc33 (diff)
downloadcryptopp-git-8b52a03d0873bf3f252c58c76df1e4167fc33fa6.tar.gz
Fix SunCC 12.2 compiler crash with GCM_Xor16_SSE2
SunCC 12.3 through 12.5 still cannot handle CLMUL, though. It would be nice if Sun fixed the regression.
Diffstat (limited to 'gcm.cpp')
-rw-r--r--gcm.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/gcm.cpp b/gcm.cpp
index 72d23890..c029ae1b 100644
--- a/gcm.cpp
+++ b/gcm.cpp
@@ -27,15 +27,15 @@
# undef CRYPTOPP_CLMUL_AVAILABLE
#endif
+#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
+# include <emmintrin.h>
+#endif
+
#include "gcm.h"
#include "cpu.h"
NAMESPACE_BEGIN(CryptoPP)
-#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE)
-# include "emmintrin.h"
-#endif
-
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
// Different assemblers accept different mnemonics: 'movd eax, xmm0' vs
// 'movd rax, xmm0' vs 'mov eax, xmm0' vs 'mov rax, xmm0'
@@ -77,20 +77,24 @@ static inline void Xor16(byte *a, const byte *b, const byte *c)
}
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
+// SunCC 5.10-5.11 compiler crash. Move GCM_Xor16_SSE2 out-of-line, and place in
+// a source file with a SSE architecture switch. Also see GH #226 and GH #284.
+# if defined (__SUNPRO_CC)
+extern void GCM_Xor16_SSE2(byte *a, const byte *b, const byte *c);
+# else
static inline void GCM_Xor16_SSE2(byte *a, const byte *b, const byte *c)
{
-// 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)
+# if CRYPTOPP_SSE2_ASM_AVAILABLE
asm ("movdqa %1, %%xmm0; pxor %2, %%xmm0; movdqa %%xmm0, %0;"
- : "=m" (a[0]) : "m"(b[0]), "m"(c[0]));
-# else // CRYPTOPP_SSE2_INTRIN_AVAILABLE
+ : "=m" (a[0]) : "rm"(b[0]), "rm"(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
}
-#endif
+# endif // SunCC
+#endif // SSE2
#if CRYPTOPP_CLMUL_AVAILABLE
extern void GCM_SetKeyWithoutResync_CLMUL(const byte *hashKey, byte *mulTable, unsigned int tableSize);