Remove BOOL macro value (GH #462)

Currently the CRYPTOPP_BOOL_XXX macros set the macro value to 0 or 1. If we remove setting the 0 value (the #else part of the expression), then the self tests speed up by about 0.3 seconds. I can't explain it, but I have observed it repeatedly.
This check-in prepares for the removal in Upstream master
pull/464/head
Jeffrey Walton 2017-08-20 21:25:29 -04:00 committed by GitHub
parent bac3c1cc40
commit 7851a0d510
17 changed files with 81 additions and 92 deletions

View File

@ -72,7 +72,7 @@ void ChaCha_Policy<R>::SeekToIteration(lword iterationCount)
template<unsigned int R> template<unsigned int R>
unsigned int ChaCha_Policy<R>::GetAlignment() const unsigned int ChaCha_Policy<R>::GetAlignment() const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && 0 #if CRYPTOPP_SSE2_ASM_AVAILABLE && 0
if (HasSSE2()) if (HasSSE2())
return 16; return 16;
else else
@ -83,7 +83,7 @@ unsigned int ChaCha_Policy<R>::GetAlignment() const
template<unsigned int R> template<unsigned int R>
unsigned int ChaCha_Policy<R>::GetOptimalBlockSize() const unsigned int ChaCha_Policy<R>::GetOptimalBlockSize() const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && 0 #if CRYPTOPP_SSE2_ASM_AVAILABLE && 0
if (HasSSE2()) if (HasSSE2())
return 4*BYTES_PER_ITERATION; return 4*BYTES_PER_ITERATION;
else else

View File

@ -400,21 +400,15 @@ NAMESPACE_END
// the System V ABI specs calls out, like on some Solaris installations and just about any 32-bit system with Clang. // the System V ABI specs calls out, like on some Solaris installations and just about any 32-bit system with Clang.
#if (defined(__ILP32__) || defined(_ILP32)) && defined(__x86_64__) #if (defined(__ILP32__) || defined(_ILP32)) && defined(__x86_64__)
#define CRYPTOPP_BOOL_X32 1 #define CRYPTOPP_BOOL_X32 1
#else
#define CRYPTOPP_BOOL_X32 0
#endif #endif
// see http://predef.sourceforge.net/prearch.html // see http://predef.sourceforge.net/prearch.html
#if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32 #if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
#define CRYPTOPP_BOOL_X86 1 #define CRYPTOPP_BOOL_X86 1
#else
#define CRYPTOPP_BOOL_X86 0
#endif #endif
#if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32 #if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
#define CRYPTOPP_BOOL_X64 1 #define CRYPTOPP_BOOL_X64 1
#else
#define CRYPTOPP_BOOL_X64 0
#endif #endif
// Undo the ASM and Intrinsic related defines due to X32. // Undo the ASM and Intrinsic related defines due to X32.
@ -426,16 +420,12 @@ NAMESPACE_END
#if defined(__arm__) || defined(__aarch32__) || defined(_M_ARM) #if defined(__arm__) || defined(__aarch32__) || defined(_M_ARM)
#define CRYPTOPP_BOOL_ARM32 1 #define CRYPTOPP_BOOL_ARM32 1
#else
#define CRYPTOPP_BOOL_ARM32 0
#endif #endif
// Microsoft plans to support ARM-64, but its not clear how to detect it. // Microsoft plans to support ARM-64, but its not clear how to detect it.
// TODO: Add MSC_VER and ARM-64 platform define when available // TODO: Add MSC_VER and ARM-64 platform define when available
#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) #if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
#define CRYPTOPP_BOOL_ARM64 1 #define CRYPTOPP_BOOL_ARM64 1
#else
#define CRYPTOPP_BOOL_ARM64 0
#endif #endif
#if defined(_MSC_VER) || defined(__BORLANDC__) #if defined(_MSC_VER) || defined(__BORLANDC__)
@ -464,11 +454,11 @@ NAMESPACE_END
#define CRYPTOPP_X86_ASM_AVAILABLE 1 #define CRYPTOPP_X86_ASM_AVAILABLE 1
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__)) #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 #define CRYPTOPP_SSE2_ASM_AVAILABLE 1
#endif #endif
#if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || defined(__SSSE3__)) #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || defined(__SSSE3__))
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1 #define CRYPTOPP_SSSE3_ASM_AVAILABLE 1
#endif #endif
#endif #endif
@ -581,7 +571,7 @@ NAMESPACE_END
// ***************** Miscellaneous ******************** // ***************** Miscellaneous ********************
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || CRYPTOPP_ARM_NEON_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
#define CRYPTOPP_BOOL_ALIGN16 1 #define CRYPTOPP_BOOL_ALIGN16 1
#else #else
#define CRYPTOPP_BOOL_ALIGN16 0 #define CRYPTOPP_BOOL_ALIGN16 0
@ -600,9 +590,6 @@ NAMESPACE_END
#define CRYPTOPP_NO_ALIGNED_ALLOC #define CRYPTOPP_NO_ALIGNED_ALLOC
#endif #endif
// Apple always provides 16-byte aligned, and tells us to use calloc
// http://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html
// how to disable inlining // how to disable inlining
#if defined(_MSC_VER) #if defined(_MSC_VER)
# define CRYPTOPP_NOINLINE_DOTDOTDOT # define CRYPTOPP_NOINLINE_DOTDOTDOT

View File

@ -148,7 +148,7 @@ static bool CPU_ProbeSSE2()
#elif defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY) #elif defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
__try __try
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
AS2(por xmm0, xmm0) // executing SSE2 instruction AS2(por xmm0, xmm0) // executing SSE2 instruction
#elif CRYPTOPP_SSE2_INTRIN_AVAILABLE #elif CRYPTOPP_SSE2_INTRIN_AVAILABLE
__m128i x = _mm_setzero_si128(); __m128i x = _mm_setzero_si128();
@ -180,7 +180,7 @@ static bool CPU_ProbeSSE2()
result = false; result = false;
else else
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
__asm __volatile ("por %xmm0, %xmm0"); __asm __volatile ("por %xmm0, %xmm0");
#elif CRYPTOPP_SSE2_INTRIN_AVAILABLE #elif CRYPTOPP_SSE2_INTRIN_AVAILABLE
__m128i x = _mm_setzero_si128(); __m128i x = _mm_setzero_si128();

2
cpu.h
View File

@ -42,7 +42,7 @@
#define CRYPTOPP_X86_ASM_AVAILABLE #define CRYPTOPP_X86_ASM_AVAILABLE
#define CRYPTOPP_BOOL_X64 1 #define CRYPTOPP_BOOL_X64 1
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 #define CRYPTOPP_SSE2_ASM_AVAILABLE 1
#define NAMESPACE_END #define NAMESPACE_END
#else #else

View File

@ -16,7 +16,7 @@
# undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
#endif #endif
// Clang and GCC hoops... // Clang and GCC hoops...

14
gcm.cpp
View File

@ -18,7 +18,7 @@
# undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
#endif #endif
// SunCC 5.13 and below crash with AES-NI/CLMUL and C++{03|11}. Disable one or the other. // SunCC 5.13 and below crash with AES-NI/CLMUL and C++{03|11}. Disable one or the other.
@ -76,7 +76,7 @@ inline static void Xor16(byte *a, const byte *b, const byte *c)
((word64 *)(void *)a)[1] = ((word64 *)(void *)b)[1] ^ ((word64 *)(void *)c)[1]; ((word64 *)(void *)a)[1] = ((word64 *)(void *)b)[1] ^ ((word64 *)(void *)c)[1];
} }
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
inline static void GCM_Xor16_SSE2(byte *a, const byte *b, const byte *c) inline static 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) // SunCC 5.14 crash (bewildering since asserts are not in effect in release builds)
@ -197,7 +197,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const
for (i=0; i<16; i++) for (i=0; i<16; i++)
{ {
memset(mulTable+i*256*16, 0, 16); memset(mulTable+i*256*16, 0, 16);
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
if (HasSSE2()) if (HasSSE2())
for (j=2; j<=0x80; j*=2) for (j=2; j<=0x80; j*=2)
for (k=1; k<j; k++) for (k=1; k<j; k++)
@ -249,7 +249,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const
{ {
memset(mulTable+i*256, 0, 16); memset(mulTable+i*256, 0, 16);
memset(mulTable+1024+i*256, 0, 16); memset(mulTable+1024+i*256, 0, 16);
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
if (HasSSE2()) if (HasSSE2())
for (j=2; j<=8; j*=2) for (j=2; j<=8; j*=2)
for (k=1; k<j; k++) for (k=1; k<j; k++)
@ -341,7 +341,7 @@ void GCM_Base::Resync(const byte *iv, size_t len)
unsigned int GCM_Base::OptimalDataAlignment() const unsigned int GCM_Base::OptimalDataAlignment() const
{ {
return return
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
HasSSE2() ? 16 : HasSSE2() ? 16 :
#elif CRYPTOPP_ARM_NEON_AVAILABLE #elif CRYPTOPP_ARM_NEON_AVAILABLE
HasNEON() ? 4 : HasNEON() ? 4 :
@ -383,7 +383,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
CRYPTOPP_ASSERT(IsAlignedOn(hashBuffer,GetAlignmentOf<word64>())); CRYPTOPP_ASSERT(IsAlignedOn(hashBuffer,GetAlignmentOf<word64>()));
switch (2*(m_buffer.size()>=64*1024) switch (2*(m_buffer.size()>=64*1024)
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
+ HasSSE2() + HasSSE2()
//#elif CRYPTOPP_ARM_NEON_AVAILABLE //#elif CRYPTOPP_ARM_NEON_AVAILABLE
// + HasNEON() // + HasNEON()
@ -531,7 +531,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
return len % 16; return len % 16;
#endif #endif
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
case 1: // SSE2 and 2K tables case 1: // SSE2 and 2K tables
{ {
#ifdef __GNUC__ #ifdef __GNUC__

View File

@ -95,12 +95,10 @@
# undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE # undef CRYPTOPP_SSSE3_ASM_AVAILABLE
# define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
# define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
#else #else
# define CRYPTOPP_INTEGER_SSE2 (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86)) # define CRYPTOPP_INTEGER_SSE2 (CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86))
#endif #endif
// ***************** C++ Static Initialization ******************** // ***************** C++ Static Initialization ********************
@ -936,7 +934,7 @@ CRYPTOPP_NAKED int CRYPTOPP_FASTCALL SSE2_Sub(size_t N, word *C, const word *A,
AddEpilogue AddEpilogue
} }
#endif // CRYPTOPP_INTEGER_SSE2 #endif // CRYPTOPP_INTEGER_SSE2
#else // CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #else // CRYPTOPP_SSE2_ASM_AVAILABLE
int CRYPTOPP_FASTCALL Baseline_Add(size_t N, word *C, const word *A, const word *B) int CRYPTOPP_FASTCALL Baseline_Add(size_t N, word *C, const word *A, const word *B)
{ {
CRYPTOPP_ASSERT (N%2 == 0); CRYPTOPP_ASSERT (N%2 == 0);

View File

@ -21,7 +21,7 @@ template <class B>
void Panama<B>::Reset() void Panama<B>::Reset()
{ {
memset(m_state, 0, m_state.SizeInBytes()); memset(m_state, 0, m_state.SizeInBytes());
#if CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) #if CRYPTOPP_SSSE3_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_PANAMA_ASM)
m_state[17] = HasSSSE3(); m_state[17] = HasSSSE3();
#endif #endif
} }
@ -32,7 +32,7 @@ void Panama<B>::Reset()
extern "C" { extern "C" {
void Panama_SSE2_Pull(size_t count, word32 *state, word32 *z, const word32 *y); void Panama_SSE2_Pull(size_t count, word32 *state, word32 *z, const word32 *y);
} }
#elif CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) #elif CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_PANAMA_ASM)
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
Panama_SSE2_Pull PROC FRAME Panama_SSE2_Pull PROC FRAME
@ -88,7 +88,7 @@ void CRYPTOPP_NOINLINE Panama_SSE2_Pull(size_t count, word32 *state, word32 *z,
ASL(4) ASL(4)
// gamma and pi // gamma and pi
#if CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE #if CRYPTOPP_SSSE3_ASM_AVAILABLE
AS2( test AS_REG_6, 1) AS2( test AS_REG_6, 1)
ASJ( jnz, 6, f) ASJ( jnz, 6, f)
#endif #endif
@ -99,7 +99,7 @@ void CRYPTOPP_NOINLINE Panama_SSE2_Pull(size_t count, word32 *state, word32 *z,
AS2( movdqa xmm7, xmm3) AS2( movdqa xmm7, xmm3)
AS2( movss xmm7, xmm6) AS2( movss xmm7, xmm6)
ASS( pshufd xmm6, xmm7, 0, 3, 2, 1) ASS( pshufd xmm6, xmm7, 0, 3, 2, 1)
#if CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE #if CRYPTOPP_SSSE3_ASM_AVAILABLE
ASJ( jmp, 7, f) ASJ( jmp, 7, f)
ASL(6) ASL(6)
AS2( movdqa xmm5, xmm3) AS2( movdqa xmm5, xmm3)
@ -206,7 +206,7 @@ void CRYPTOPP_NOINLINE Panama_SSE2_Pull(size_t count, word32 *state, word32 *z,
AS2( movdqa xmm1, XMMWORD_PTR [AS_REG_2+1*16]) AS2( movdqa xmm1, XMMWORD_PTR [AS_REG_2+1*16])
AS2( movdqa xmm0, XMMWORD_PTR [AS_REG_2+0*16]) AS2( movdqa xmm0, XMMWORD_PTR [AS_REG_2+0*16])
#if CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE #if CRYPTOPP_SSSE3_ASM_AVAILABLE
AS2( test AS_REG_6, 1) AS2( test AS_REG_6, 1)
ASJ( jnz, 8, f) ASJ( jnz, 8, f)
#endif #endif
@ -223,7 +223,7 @@ void CRYPTOPP_NOINLINE Panama_SSE2_Pull(size_t count, word32 *state, word32 *z,
ASS( pshufd xmm6, xmm6, 0, 3, 2, 1) ASS( pshufd xmm6, xmm6, 0, 3, 2, 1)
ASS( pshufd xmm5, xmm5, 0, 3, 2, 1) ASS( pshufd xmm5, xmm5, 0, 3, 2, 1)
ASS( pshufd xmm4, xmm4, 0, 3, 2, 1) ASS( pshufd xmm4, xmm4, 0, 3, 2, 1)
#if CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE #if CRYPTOPP_SSSE3_ASM_AVAILABLE
ASJ( jmp, 9, f) ASJ( jmp, 9, f)
ASL(8) ASL(8)
AS2( movd xmm7, eax) AS2( movd xmm7, eax)
@ -319,7 +319,7 @@ void CRYPTOPP_NOINLINE Panama_SSE2_Pull(size_t count, word32 *state, word32 *z,
#else #else
} }
#endif #endif
#endif // #ifdef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #endif // #ifdef CRYPTOPP_SSE2_ASM_AVAILABLE
#ifndef CRYPTOPP_GENERATE_X64_MASM #ifndef CRYPTOPP_GENERATE_X64_MASM
@ -477,7 +477,7 @@ void PanamaCipherPolicy<B>::CipherResynchronize(byte *keystreamBuffer, const byt
this->Iterate(1, buf); this->Iterate(1, buf);
} }
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) #if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM)
if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2() && !IsP4()) // SSE2 code is slower on P4 Prescott if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2() && !IsP4()) // SSE2 code is slower on P4 Prescott
Panama_SSE2_Pull(32, this->m_state, NULLPTR, NULLPTR); Panama_SSE2_Pull(32, this->m_state, NULLPTR, NULLPTR);
else else
@ -488,7 +488,7 @@ void PanamaCipherPolicy<B>::CipherResynchronize(byte *keystreamBuffer, const byt
template <class B> template <class B>
unsigned int PanamaCipherPolicy<B>::GetAlignment() const unsigned int PanamaCipherPolicy<B>::GetAlignment() const
{ {
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) #if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM)
if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2()) if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2())
return 16; return 16;
else else
@ -499,7 +499,7 @@ unsigned int PanamaCipherPolicy<B>::GetAlignment() const
template <class B> template <class B>
void PanamaCipherPolicy<B>::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) void PanamaCipherPolicy<B>::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
{ {
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) #if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM)
if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2()) if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2())
Panama_SSE2_Pull(iterationCount, this->m_state, (word32 *)(void *)output, (const word32 *)(void *)input); Panama_SSE2_Pull(iterationCount, this->m_state, (word32 *)(void *)output, (const word32 *)(void *)input);
else else

View File

@ -86,7 +86,7 @@ NAMESPACE_BEGIN(CryptoPP)
#endif #endif
// Hack for http://github.com/weidai11/cryptopp/issues/42 and http://github.com/weidai11/cryptopp/issues/132 // Hack for http://github.com/weidai11/cryptopp/issues/42 and http://github.com/weidai11/cryptopp/issues/132
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) #if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS)
# define CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS 1 # define CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS 1
#endif #endif
@ -102,7 +102,7 @@ NAMESPACE_BEGIN(CryptoPP)
#define CONST_M128I_CAST(x) ((const __m128i *)(const void *)(x)) #define CONST_M128I_CAST(x) ((const __m128i *)(const void *)(x))
#if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS) #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS)
# if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM) # if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM)
namespace rdtable {CRYPTOPP_ALIGN_DATA(16) word64 Te[256+2];} namespace rdtable {CRYPTOPP_ALIGN_DATA(16) word64 Te[256+2];}
using namespace rdtable; using namespace rdtable;
# else # else
@ -201,7 +201,7 @@ void Rijndael::Base::FillEncTable()
} }
#endif #endif
} }
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM) #if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM)
Te[256] = Te[257] = 0; Te[256] = Te[257] = 0;
#endif #endif
s_TeFilled = true; s_TeFilled = true;
@ -349,8 +349,8 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLen, c
void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) || CRYPTOPP_AESNI_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) || CRYPTOPP_AESNI_AVAILABLE
# if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM) # if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM)
if (HasSSE2()) if (HasSSE2())
# else # else
if (HasAESNI()) if (HasAESNI())
@ -542,7 +542,7 @@ void Rijndael::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock
#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM #endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM) #if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM)
CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *locals, const word32 *k) CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *locals, const word32 *k)
{ {
@ -1095,7 +1095,7 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo
return Rijndael_Enc_AdvancedProcessBlocks_ARMV8(m_key, m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); return Rijndael_Enc_AdvancedProcessBlocks_ARMV8(m_key, m_rounds, inBlocks, xorBlocks, outBlocks, length, flags);
#endif #endif
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM) #if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM)
if (HasSSE2()) if (HasSSE2())
{ {
if (length < BLOCKSIZE) if (length < BLOCKSIZE)

View File

@ -24,10 +24,8 @@
# undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE # undef CRYPTOPP_SSSE3_ASM_AVAILABLE
# define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
# define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
#endif #endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
@ -79,7 +77,7 @@ void Salsa20_Policy::SeekToIteration(lword iterationCount)
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SALSA_ASM) #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SALSA_ASM)
unsigned int Salsa20_Policy::GetAlignment() const unsigned int Salsa20_Policy::GetAlignment() const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
if (HasSSE2()) if (HasSSE2())
return 16; return 16;
else else
@ -89,7 +87,7 @@ unsigned int Salsa20_Policy::GetAlignment() const
unsigned int Salsa20_Policy::GetOptimalBlockSize() const unsigned int Salsa20_Policy::GetOptimalBlockSize() const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
if (HasSSE2()) if (HasSSE2())
return 4*BYTES_PER_ITERATION; return 4*BYTES_PER_ITERATION;
else else
@ -117,7 +115,7 @@ void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output
return; return;
#endif #endif
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
ALIGN 8 ALIGN 8
Salsa20_OperateKeystream PROC FRAME Salsa20_OperateKeystream PROC FRAME

30
sha.cpp
View File

@ -41,11 +41,17 @@
#include "misc.h" #include "misc.h"
#include "cpu.h" #include "cpu.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
#if defined(CRYPTOPP_DISABLE_SHA_ASM) #if defined(CRYPTOPP_DISABLE_SHA_ASM)
# undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
#endif #endif
// C++ makes const internal linkage // C++ makes const internal linkage
@ -455,7 +461,7 @@ void CRYPTOPP_FASTCALL SHA256_HashMultipleBlocks_SSE2(word32 *state, const word3
AS2( mov DATA_END, WORD_REG(ax)) AS2( mov DATA_END, WORD_REG(ax))
AS2( mov K_END, WORD_REG(si)) AS2( mov K_END, WORD_REG(si))
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
AS2( test edi, 1) AS2( test edi, 1)
ASJ( jnz, 2, f) ASJ( jnz, 2, f)
@ -466,7 +472,7 @@ void CRYPTOPP_FASTCALL SHA256_HashMultipleBlocks_SSE2(word32 *state, const word3
#endif #endif
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
ASJ( jmp, 0, f) ASJ( jmp, 0, f)
#endif #endif
ASL(2) // non-SSE2 ASL(2) // non-SSE2
@ -480,7 +486,7 @@ INTEL_NOPREFIX
ASJ( jmp, 3, f) ASJ( jmp, 3, f)
#endif #endif
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
ASL(0) ASL(0)
AS2( movdqu E(0), xmm1) AS2( movdqu E(0), xmm1)
AS2( movdqu A(0), xmm0) AS2( movdqu A(0), xmm0)
@ -545,7 +551,7 @@ INTEL_NOPREFIX
AS2( mov AS_REG_7, STATE_SAVE) AS2( mov AS_REG_7, STATE_SAVE)
AS2( mov DATA_SAVE, WORD_REG(dx)) AS2( mov DATA_SAVE, WORD_REG(dx))
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
AS2( test DWORD PTR K_END, 1) AS2( test DWORD PTR K_END, 1)
ASJ( jz, 4, f) ASJ( jz, 4, f)
@ -563,7 +569,7 @@ INTEL_NOPREFIX
#endif #endif
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
ASJ( jmp, 5, f) ASJ( jmp, 5, f)
ASL(4) // non-SSE2 ASL(4) // non-SSE2
#endif #endif
@ -584,7 +590,7 @@ INTEL_NOPREFIX
AS2( mov ecx, AS_REG_7d) AS2( mov ecx, AS_REG_7d)
AS2( cmp WORD_REG(dx), DATA_END) AS2( cmp WORD_REG(dx), DATA_END)
ASJ( jb, 2, b) ASJ( jb, 2, b)
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
ASL(5) ASL(5)
#endif #endif
#endif #endif
@ -667,7 +673,7 @@ size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length)
return length & (SHA256::BLOCKSIZE - 1); return length & (SHA256::BLOCKSIZE - 1);
} }
#endif #endif
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
if (HasSSE2()) if (HasSSE2())
{ {
const size_t res = length & (SHA256::BLOCKSIZE - 1); const size_t res = length & (SHA256::BLOCKSIZE - 1);
@ -716,7 +722,7 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length)
return length & (SHA256::BLOCKSIZE - 1); return length & (SHA256::BLOCKSIZE - 1);
} }
#endif #endif
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
if (HasSSE2()) if (HasSSE2())
{ {
const size_t res = length & (SHA256::BLOCKSIZE - 1); const size_t res = length & (SHA256::BLOCKSIZE - 1);
@ -819,7 +825,7 @@ const word64 SHA512_K[80] CRYPTOPP_SECTION_ALIGN16 = {
W64LIT(0x5fcb6fab3ad6faec), W64LIT(0x6c44198c4a475817) W64LIT(0x5fcb6fab3ad6faec), W64LIT(0x6c44198c4a475817)
}; };
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) #if CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)
ANONYMOUS_NAMESPACE_BEGIN ANONYMOUS_NAMESPACE_BEGIN
@ -1019,7 +1025,7 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL SHA512_HashBlock_SSE2(word64 *state, const
ANONYMOUS_NAMESPACE_END ANONYMOUS_NAMESPACE_END
#endif // CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #endif // CRYPTOPP_SSE2_ASM_AVAILABLE
ANONYMOUS_NAMESPACE_BEGIN ANONYMOUS_NAMESPACE_BEGIN
@ -1066,7 +1072,7 @@ void SHA512::Transform(word64 *state, const word64 *data)
CRYPTOPP_ASSERT(state); CRYPTOPP_ASSERT(state);
CRYPTOPP_ASSERT(data); CRYPTOPP_ASSERT(data);
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) #if CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)
if (HasSSE2()) if (HasSSE2())
{ {
SHA512_HashBlock_SSE2(state, data); SHA512_HashBlock_SSE2(state, data);

12
sha.h
View File

@ -11,10 +11,10 @@
#include "config.h" #include "config.h"
#include "iterhash.h" #include "iterhash.h"
// Clang 3.3 integrated assembler crash on Linux #if (CRYPTOPP_BOOL_X86)
// http://github.com/weidai11/cryptopp/issues/264 # define SHA_X86_ALIGN16 true
#if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400) #else
# define CRYPTOPP_DISABLE_SHA_ASM # define SHA_X86_ALIGN16 false
#endif #endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
@ -131,7 +131,7 @@ protected:
//! \brief SHA-512 message digest //! \brief SHA-512 message digest
//! \sa <a href="http://www.weidai.com/scan-mirror/md.html#SHA-512">SHA-512</a> //! \sa <a href="http://www.weidai.com/scan-mirror/md.html#SHA-512">SHA-512</a>
//! \since Crypto++ 4.0 //! \since Crypto++ 4.0
class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, (CRYPTOPP_BOOL_X86|CRYPTOPP_BOOL_X32)> class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, SHA_X86_ALIGN16>
{ {
public: public:
//! \brief Initialize state array //! \brief Initialize state array
@ -164,7 +164,7 @@ public:
//! \brief SHA-384 message digest //! \brief SHA-384 message digest
//! \sa <a href="http://www.weidai.com/scan-mirror/md.html#SHA-384">SHA-384</a> //! \sa <a href="http://www.weidai.com/scan-mirror/md.html#SHA-384">SHA-384</a>
//! \since Crypto++ 4.0 //! \since Crypto++ 4.0
class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, (CRYPTOPP_BOOL_X86|CRYPTOPP_BOOL_X32)> class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, SHA_X86_ALIGN16>
{ {
public: public:
//! \brief Initialize state array //! \brief Initialize state array

View File

@ -291,7 +291,7 @@ word32 s_sosemanukMulTables[512] = {
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM) #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM)
unsigned int SosemanukPolicy::GetAlignment() const unsigned int SosemanukPolicy::GetAlignment() const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM) #if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM)
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
if (HasSSE2() && !IsP4()) // Intel compiler produces faster code for this algorithm on the P4 if (HasSSE2() && !IsP4()) // Intel compiler produces faster code for this algorithm on the P4
#else #else
@ -305,7 +305,7 @@ unsigned int SosemanukPolicy::GetAlignment() const
unsigned int SosemanukPolicy::GetOptimalBlockSize() const unsigned int SosemanukPolicy::GetOptimalBlockSize() const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM) #if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM)
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
if (HasSSE2() && !IsP4()) // Intel compiler produces faster code for this algorithm on the P4 if (HasSSE2() && !IsP4()) // Intel compiler produces faster code for this algorithm on the P4
#else #else
@ -333,7 +333,7 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu
return; return;
#endif #endif
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM) #if CRYPTOPP_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM)
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
ALIGN 8 ALIGN 8
Sosemanuk_OperateKeystream PROC FRAME Sosemanuk_OperateKeystream PROC FRAME

View File

@ -11,7 +11,7 @@
# undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
#endif #endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
@ -41,7 +41,7 @@ void Tiger::TruncatedFinal(byte *hash, size_t size)
void Tiger::Transform (word64 *digest, const word64 *X) void Tiger::Transform (word64 *digest, const word64 *X)
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) #if CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)
if (HasSSE2()) if (HasSSE2())
{ {
#ifdef __GNUC__ #ifdef __GNUC__

View File

@ -58,6 +58,8 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#undef BLOCKING_RNG_AVAILABLE
#include "validate.h" #include "validate.h"
// Aggressive stack checking with VS2005 SP1 and above. // Aggressive stack checking with VS2005 SP1 and above.

View File

@ -13,7 +13,7 @@
# undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
#endif #endif
#if CRYPTOPP_MSC_VERSION #if CRYPTOPP_MSC_VERSION
@ -161,13 +161,13 @@ void VMAC_Base::HashEndianCorrectedBlock(const word64 *data)
unsigned int VMAC_Base::OptimalDataAlignment() const unsigned int VMAC_Base::OptimalDataAlignment() const
{ {
return return
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
HasSSE2() ? 16 : HasSSE2() ? 16 :
#endif #endif
GetCipher().OptimalDataAlignment(); GetCipher().OptimalDataAlignment();
} }
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) #if CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)
#if CRYPTOPP_MSC_VERSION #if CRYPTOPP_MSC_VERSION
# pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code # pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code
#endif #endif
@ -800,7 +800,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) inline void VMAC_Base::VHASH_Update(const word64 *data, size_t blocksRemainingInWord64)
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) #if CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)
if (HasSSE2()) if (HasSSE2())
{ {
VHASH_Update_SSE2(data, blocksRemainingInWord64, 0); VHASH_Update_SSE2(data, blocksRemainingInWord64, 0);

View File

@ -77,10 +77,8 @@
// "Inline assembly operands don't work with .intel_syntax", // "Inline assembly operands don't work with .intel_syntax",
// http://llvm.org/bugs/show_bug.cgi?id=24232 // http://llvm.org/bugs/show_bug.cgi?id=24232
#if defined(CRYPTOPP_DISABLE_INTEL_ASM) #if defined(CRYPTOPP_DISABLE_INTEL_ASM)
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE # undef CRYPTOPP_SSSE3_ASM_AVAILABLE
# define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
# define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
#endif #endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
@ -128,7 +126,7 @@ void Whirlpool::TruncatedFinal(byte *hash, size_t size)
* employed). * employed).
*/ */
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
CRYPTOPP_ALIGN_DATA(16) static const word64 Whirlpool_C[4*256+R] CRYPTOPP_SECTION_ALIGN16 = { CRYPTOPP_ALIGN_DATA(16) static const word64 Whirlpool_C[4*256+R] CRYPTOPP_SECTION_ALIGN16 = {
#else #else
static const word64 Whirlpool_C[4*256+R] = { static const word64 Whirlpool_C[4*256+R] = {
@ -408,7 +406,7 @@ static const word64 Whirlpool_C[4*256+R] = {
// Whirlpool basic transformation. Transforms state based on block. // Whirlpool basic transformation. Transforms state based on block.
void Whirlpool::Transform(word64 *digest, const word64 *block) void Whirlpool::Transform(word64 *digest, const word64 *block)
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
if (HasSSE2()) if (HasSSE2())
{ {
// MMX version has the same structure as C version below // MMX version has the same structure as C version below