diff --git a/blake2.cpp b/blake2.cpp index df2a709e..c696169e 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -14,7 +14,7 @@ // Do so in both blake2.cpp and blake2-simd.cpp. // #undef CRYPTOPP_SSE41_AVAILABLE // #undef CRYPTOPP_ARM_NEON_AVAILABLE -// #undef CRYPTOPP_POWER8_AVAILABLE +// #undef CRYPTOPP_ALTIVEC_AVAILABLE // Disable NEON/ASIMD for Cortex-A53 and A57. The shifts are too slow and C/C++ is about // 3 cpb faster than NEON/ASIMD. Also see http://github.com/weidai11/cryptopp/issues/367. @@ -22,9 +22,9 @@ # undef CRYPTOPP_ARM_NEON_AVAILABLE #endif -// Disable POWER7 on PowerPC big-endian machines. Blake2s/POWER7 runs slower than C++. -#if defined(__powerpc__) && defined(__BIG_ENDIAN__) +#if !(CRYPTOPP_ALTIVEC_AVAILABLE) # undef CRYPTOPP_POWER7_AVAILABLE +# undef CRYPTOPP_POWER8_AVAILABLE #endif ANONYMOUS_NAMESPACE_BEGIN diff --git a/blake2b-simd.cpp b/blake2b-simd.cpp index 5a7f65d3..fa850e66 100644 --- a/blake2b-simd.cpp +++ b/blake2b-simd.cpp @@ -1,6 +1,6 @@ - // blake2-simd.cpp - written and placed in the public domain by -// Jeffrey Walton, Uri Blumenthal and Marcel Raad. +// Samuel Neves, Jeffrey Walton, Uri Blumenthal +// and Marcel Raad. // // This source file uses intrinsics to gain access to ARMv7a/ARMv8a // NEON, Power8 and SSE4.1 instructions. A separate source file is @@ -16,7 +16,7 @@ // Do so in both blake2.cpp and blake2-simd.cpp. // #undef CRYPTOPP_SSE41_AVAILABLE // #undef CRYPTOPP_ARM_NEON_AVAILABLE -// #undef CRYPTOPP_POWER8_AVAILABLE +// #undef CRYPTOPP_ALTIVEC_AVAILABLE // Disable NEON/ASIMD for Cortex-A53 and A57. The shifts are too slow and C/C++ is about // 3 cpb faster than NEON/ASIMD. Also see http://github.com/weidai11/cryptopp/issues/367. @@ -41,7 +41,7 @@ # include #endif -#if defined(CRYPTOPP_POWER8_AVAILABLE) +#if (CRYPTOPP_POWER8_AVAILABLE) # include "ppc-simd.h" #endif diff --git a/blake2s-simd.cpp b/blake2s-simd.cpp index 5db4caa2..fd1bc006 100644 --- a/blake2s-simd.cpp +++ b/blake2s-simd.cpp @@ -1,6 +1,6 @@ - // blake2-simd.cpp - written and placed in the public domain by -// Jeffrey Walton, Uri Blumenthal and Marcel Raad. +// Samuel Neves, Jeffrey Walton, Uri Blumenthal +// and Marcel Raad. // // This source file uses intrinsics to gain access to ARMv7a/ARMv8a // NEON, Power7 and SSE4.1 instructions. A separate source file is @@ -16,7 +16,7 @@ // Do so in both blake2.cpp and blake2-simd.cpp. // #undef CRYPTOPP_SSE41_AVAILABLE // #undef CRYPTOPP_ARM_NEON_AVAILABLE -// #undef CRYPTOPP_POWER7_AVAILABLE +// #undef CRYPTOPP_ALTIVEC_AVAILABLE // Disable NEON/ASIMD for Cortex-A53 and A57. The shifts are too slow and C/C++ is about // 3 cpb faster than NEON/ASIMD. Also see http://github.com/weidai11/cryptopp/issues/367. @@ -41,15 +41,10 @@ # include #endif -#if defined(CRYPTOPP_POWER7_AVAILABLE) +#if (CRYPTOPP_POWER7_AVAILABLE) # include "ppc-simd.h" #endif -// Disable POWER7 on PowerPC big-endian machines. Blake2s/POWER7 runs slower than C++. -#if defined(__powerpc__) && defined(__BIG_ENDIAN__) -# undef CRYPTOPP_POWER7_AVAILABLE -#endif - ANONYMOUS_NAMESPACE_BEGIN using CryptoPP::word32; diff --git a/ppc-simd.h b/ppc-simd.h index 35abd507..2bbf35b7 100644 --- a/ppc-simd.h +++ b/ppc-simd.h @@ -27,8 +27,6 @@ // We also need to handle the case of -DCRYPTOPP_ALTIVEC_AVAILABLE=0. #if !defined(__ALTIVEC__) # undef CRYPTOPP_ALTIVEC_AVAILABLE -# undef CRYPTOPP_POWER7_AVAILABLE -# undef CRYPTOPP_POWER8_AVAILABLE #endif #if !defined(_ARCH_PWR7) @@ -49,8 +47,19 @@ # undef bool #endif +#if !(CRYPTOPP_ALTIVEC_AVAILABLE) +# undef CRYPTOPP_POWER7_AVAILABLE +# undef CRYPTOPP_POWER8_AVAILABLE +# undef CRYPTOPP_POWER8_AES_AVAILABLE +# undef CRYPTOPP_POWER8_VMULL_AVAILABLE +# undef CRYPTOPP_POWER8_SHA_AVAILABLE +#endif + NAMESPACE_BEGIN(CryptoPP) +// Wrap everything in this file based on CRYPTOPP_ALTIVEC_AVAILABLE +#if (CRYPTOPP_ALTIVEC_AVAILABLE) + // Datatypes #if (CRYPTOPP_ALTIVEC_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) typedef __vector unsigned char uint8x16_p; @@ -842,6 +851,8 @@ inline T VectorSHA512(const T& vec) #endif // POWER8 crypto +#endif // CRYPTOPP_ALTIVEC_AVAILABLE + NAMESPACE_END #endif // CRYPTOPP_PPC_CRYPTO_H