From 1450847e405d8f4c969c3ae5e1a30faec6cff746 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 16 Aug 2017 21:43:31 -0400 Subject: [PATCH 1/2] Update comments --- shacal2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shacal2.cpp b/shacal2.cpp index c1b9145f..9ab3b373 100644 --- a/shacal2.cpp +++ b/shacal2.cpp @@ -3,8 +3,8 @@ // Portions of this code were derived from // Wei Dai's implementation of SHA-2 // -// Jack Lloyd is the author of Botan and allowed Crypto++ to use -// parts of Botan's implementation under the same license as Crypto++ +// Jack Lloyd and the Botan team allowed Crypto++ to use parts of +// Botan's implementation under the same license as Crypto++ // is released. The code for SHACAL2_Enc_ProcessAndXorBlock_SHANI // below is Botan's x86_encrypt_blocks with minor tweaks. Many thanks // to the Botan team. Also see http://github.com/randombit/botan/. From df280a509a3c86b825475ec9456b56d3fb21cedb Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 16 Aug 2017 22:10:53 -0400 Subject: [PATCH 2/2] Disable Carryless Multiplies for Clang Clang causes too many problems. Early versions of the compiler simply crashes. Later versions of the compiler still have trouble with Intel ASM and still produce incorrect results on occassion. Additionally, we have to special case the integrated assemvler. Its making a mess of the code and causing self test failures --- gcm.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/gcm.cpp b/gcm.cpp index b27dba29..0a4207ad 100644 --- a/gcm.cpp +++ b/gcm.cpp @@ -16,16 +16,20 @@ #ifndef CRYPTOPP_IMPORTS #ifndef CRYPTOPP_GENERATE_X64_MASM -// Clang 3.3 integrated assembler crash on Linux. -#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)) +// Clang 3.3 integrated assembler crash on Linux. Other versions produce incorrect results. +// Clang has never handled Intel ASM very well. I wish LLVM would fix it. +#if defined(__clang__) +# undef CRYPTOPP_X86_ASM_AVAILABLE +# undef CRYPTOPP_X32_ASM_AVAILABLE +# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #endif // SunCC 5.13 and below crash with AES-NI/CLMUL and C++{03|11}. Disable one or the other. // Also see http://github.com/weidai11/cryptopp/issues/226 -#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x513) -# undef CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE -#endif +// #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x513) +// # undef CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE +// #endif // Clang casts #define M128I_CAST(x) ((__m128i *)(void *)(x)) @@ -37,21 +41,16 @@ NAMESPACE_BEGIN(CryptoPP) #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' -#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) -// 'movd eax, xmm0' only. REG_WORD() macro not used. -# define USE_MOVD_REG32 1 -#elif (defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE) -// 'movd eax, xmm0' or 'movd rax, xmm0'. REG_WORD() macro supplies REG32 or REG64. -# define USE_MOVD_REG32_OR_REG64 1 -#elif defined(__GNUC__) || defined(_MSC_VER) +// Different assemblers accept different mnemonics: 'movd eax, xmm0' vs +// 'movd rax, xmm0' vs 'mov eax, xmm0' vs 'mov rax, xmm0' +#if defined(__GNUC__) || defined(_MSC_VER) // 'movd eax, xmm0' or 'movd rax, xmm0'. REG_WORD() macro supplies REG32 or REG64. # define USE_MOVD_REG32_OR_REG64 1 #else // 'mov eax, xmm0' or 'mov rax, xmm0'. REG_WORD() macro supplies REG32 or REG64. # define USE_MOV_REG32_OR_REG64 1 #endif -#endif +#endif // CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64) && CRYPTOPP_BOOL_ARM_PMULL_AVAILABLE #if defined(__GNUC__)