diff --git a/sha.cpp b/sha.cpp index f02c0e19..441a5c65 100644 --- a/sha.cpp +++ b/sha.cpp @@ -20,6 +20,13 @@ #include "misc.h" #include "cpu.h" +#if defined(CRYPTOPP_DISABLE_SHA_ASM) +# undef CRYPTOPP_X86_ASM_AVAILABLE +# undef CRYPTOPP_X32_ASM_AVAILABLE +# undef CRYPTOPP_X64_ASM_AVAILABLE +# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE +#endif + NAMESPACE_BEGIN(CryptoPP) // start of Steve Reid's code @@ -102,7 +109,7 @@ void SHA256::InitState(HashWordType *state) memcpy(state, s, sizeof(s)); } -#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SHA_ASM) +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE CRYPTOPP_ALIGN_DATA(16) extern const word32 SHA256_K[64] CRYPTOPP_SECTION_ALIGN16 = { #else extern const word32 SHA256_K[64] = { @@ -127,7 +134,7 @@ extern const word32 SHA256_K[64] = { #endif // #ifndef CRYPTOPP_GENERATE_X64_MASM -#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_GENERATE_X64_MASM)) && !defined(CRYPTOPP_DISABLE_SHA_ASM) +#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_GENERATE_X64_MASM)) static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 *data, size_t len #if defined(_MSC_VER) && (_MSC_VER == 1200) diff --git a/sha.h b/sha.h index 7c145115..86151cc2 100644 --- a/sha.h +++ b/sha.h @@ -11,6 +11,7 @@ #include "iterhash.h" // Clang 3.3 integrated assembler crash on Linux +// http://github.com/weidai11/cryptopp/issues/264 #if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400) # define CRYPTOPP_DISABLE_SHA_ASM #endif diff --git a/tiger.cpp b/tiger.cpp index fc62be7d..d7261f92 100644 --- a/tiger.cpp +++ b/tiger.cpp @@ -7,6 +7,13 @@ #include "misc.h" #include "cpu.h" +#if defined(CRYPTOPP_DISABLE_TIGER_ASM) +# undef CRYPTOPP_X86_ASM_AVAILABLE +# undef CRYPTOPP_X32_ASM_AVAILABLE +# undef CRYPTOPP_X64_ASM_AVAILABLE +# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE +#endif + NAMESPACE_BEGIN(CryptoPP) void Tiger::InitState(HashWordType *state) diff --git a/tiger.h b/tiger.h index 395d7805..71e5964b 100644 --- a/tiger.h +++ b/tiger.h @@ -4,6 +4,12 @@ #include "config.h" #include "iterhash.h" +// Clang 3.3 integrated assembler crash on Linux +// http://github.com/weidai11/cryptopp/issues/264 +#if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400) +# define CRYPTOPP_DISABLE_TIGER_ASM +#endif + NAMESPACE_BEGIN(CryptoPP) /// Tiger diff --git a/vmac.cpp b/vmac.cpp index a6662f21..d482cc7c 100644 --- a/vmac.cpp +++ b/vmac.cpp @@ -9,6 +9,13 @@ #include "argnames.h" #include "secblock.h" +#if defined(CRYPTOPP_DISABLE_VMAC_ASM) +# undef CRYPTOPP_X86_ASM_AVAILABLE +# undef CRYPTOPP_X32_ASM_AVAILABLE +# undef CRYPTOPP_X64_ASM_AVAILABLE +# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE +#endif + #if CRYPTOPP_MSC_VERSION # pragma warning(disable: 4731) #endif @@ -154,13 +161,13 @@ void VMAC_Base::HashEndianCorrectedBlock(const word64 *data) unsigned int VMAC_Base::OptimalDataAlignment() const { return -#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_VMAC_ASM) +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) HasSSE2() ? 16 : #endif GetCipher().OptimalDataAlignment(); } -#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || (CRYPTOPP_BOOL_X32 && !defined(CRYPTOPP_DISABLE_VMAC_ASM)))) +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) #if CRYPTOPP_MSC_VERSION # pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code #endif @@ -798,7 +805,7 @@ void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemaining inline void VMAC_Base::VHASH_Update(const word64 *data, size_t blocksRemainingInWord64) { -#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || (CRYPTOPP_BOOL_X32 && !defined(CRYPTOPP_DISABLE_VMAC_ASM)))) +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) if (HasSSE2()) { VHASH_Update_SSE2(data, blocksRemainingInWord64, 0); diff --git a/vmac.h b/vmac.h index bae39971..0723b1c4 100644 --- a/vmac.h +++ b/vmac.h @@ -10,7 +10,9 @@ #include "iterhash.h" #include "seckey.h" -#if CRYPTOPP_BOOL_X32 +// Clang 3.3 integrated assembler crash on Linux +// http://github.com/weidai11/cryptopp/issues/264 +#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)) || CRYPTOPP_BOOL_X32 # define CRYPTOPP_DISABLE_VMAC_ASM #endif