Guard BLAKE2 on CRYPTOPP_ALTIVEC_AVAILABLE

This commit is contained in:
Jeffrey Walton 2018-11-03 05:50:34 -04:00
parent dfacc9f15c
commit 06867e5caf
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 24 additions and 18 deletions

View File

@ -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

View File

@ -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 <arm_acle.h>
#endif
#if defined(CRYPTOPP_POWER8_AVAILABLE)
#if (CRYPTOPP_POWER8_AVAILABLE)
# include "ppc-simd.h"
#endif

View File

@ -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 <arm_acle.h>
#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;

View File

@ -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