From 6f1caab7c2e139abf117aaa1b64ae9bc60844c54 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 14 Aug 2018 23:31:40 -0400 Subject: [PATCH] Move SIMON-64 and SPECK-64 to Power7 minimum SIMON-64 and SPECK-64 don't use 64-bit type so they can run on Power7. We may be able to drop to Power4, but we need to test the effects of Loads and Stores without vec_vxs_ld and vec_vsx_st --- simon-simd.cpp | 20 ++++++++++++-------- simon.cpp | 32 +++++++++++++++++--------------- speck-simd.cpp | 22 +++++++++++++--------- speck.cpp | 32 +++++++++++++++++--------------- 4 files changed, 59 insertions(+), 47 deletions(-) diff --git a/simon-simd.cpp b/simon-simd.cpp index 997cfaab..5984967e 100644 --- a/simon-simd.cpp +++ b/simon-simd.cpp @@ -43,7 +43,7 @@ # include #endif -#if defined(CRYPTOPP_POWER8_AVAILABLE) +#if defined(CRYPTOPP_POWER7_AVAILABLE) # include "ppc-simd.h" #endif @@ -951,9 +951,9 @@ inline void SIMON64_Dec_6_Blocks(__m128i &block0, __m128i &block1, #endif // CRYPTOPP_SSE41_AVAILABLE -// ***************************** Power8 ***************************** // +// ***************************** Power7 ***************************** // -#if defined(CRYPTOPP_POWER8_AVAILABLE) +#if defined(CRYPTOPP_POWER7_AVAILABLE) using CryptoPP::uint8x16_p; using CryptoPP::uint32x4_p; @@ -1191,7 +1191,7 @@ inline void SIMON64_Dec_6_Blocks(uint32x4_p &block0, uint32x4_p &block1, block5 = (uint32x4_p)vec_perm(x3, y3, m4); } -#endif // CRYPTOPP_POWER8_AVAILABLE +#endif // CRYPTOPP_POWER7_AVAILABLE // ***************************** Power8 ***************************** // @@ -1506,23 +1506,27 @@ size_t SIMON128_Dec_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t ro } #endif // CRYPTOPP_SSSE3_AVAILABLE -// ***************************** Power8 ***************************** // +// ***************************** Power7 ***************************** // -#if defined(CRYPTOPP_POWER8_AVAILABLE) -size_t SIMON64_Enc_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, +#if defined(CRYPTOPP_POWER7_AVAILABLE) +size_t SIMON64_Enc_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) { return AdvancedProcessBlocks64_6x2_ALTIVEC(SIMON64_Enc_Block, SIMON64_Enc_6_Blocks, subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags); } -size_t SIMON64_Dec_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, +size_t SIMON64_Dec_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) { return AdvancedProcessBlocks64_6x2_ALTIVEC(SIMON64_Dec_Block, SIMON64_Dec_6_Blocks, subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags); } +#endif +// ***************************** Power8 ***************************** // + +#if defined(CRYPTOPP_POWER8_AVAILABLE) size_t SIMON128_Enc_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) { diff --git a/simon.cpp b/simon.cpp index d6c3480c..59e74443 100644 --- a/simon.cpp +++ b/simon.cpp @@ -225,13 +225,15 @@ extern size_t SIMON128_Dec_AdvancedProcessBlocks_SSSE3(const word64* subKeys, si const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); #endif +#if (CRYPTOPP_POWER7_AVAILABLE) +extern size_t SIMON64_Enc_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, + const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); + +extern size_t SIMON64_Dec_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, + const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); +#endif + #if (CRYPTOPP_POWER8_AVAILABLE) -extern size_t SIMON64_Enc_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, - const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); - -extern size_t SIMON64_Dec_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, - const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); - extern size_t SIMON128_Enc_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); @@ -249,9 +251,9 @@ std::string SIMON64::Base::AlgorithmProvider() const if (HasNEON()) return "NEON"; #endif -#if (CRYPTOPP_POWER8_AVAILABLE) - if (HasPower8()) - return "Power8"; +#if (CRYPTOPP_POWER7_AVAILABLE) + if (HasPower7()) + return "Power7"; #endif return "C++"; } @@ -454,9 +456,9 @@ size_t SIMON64::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xor return SIMON64_Enc_AdvancedProcessBlocks_NEON(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif -#if (CRYPTOPP_POWER8_AVAILABLE) - if (HasPower8()) - return SIMON64_Enc_AdvancedProcessBlocks_POWER8(m_rkeys, (size_t)m_rounds, +#if (CRYPTOPP_POWER7_AVAILABLE) + if (HasPower7()) + return SIMON64_Enc_AdvancedProcessBlocks_POWER7(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif return BlockTransformation::AdvancedProcessBlocks(inBlocks, xorBlocks, outBlocks, length, flags); @@ -475,9 +477,9 @@ size_t SIMON64::Dec::AdvancedProcessBlocks(const byte *inBlocks, const byte *xor return SIMON64_Dec_AdvancedProcessBlocks_NEON(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif -#if (CRYPTOPP_POWER8_AVAILABLE) - if (HasPower8()) - return SIMON64_Dec_AdvancedProcessBlocks_POWER8(m_rkeys, (size_t)m_rounds, +#if (CRYPTOPP_POWER7_AVAILABLE) + if (HasPower7()) + return SIMON64_Dec_AdvancedProcessBlocks_POWER7(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif return BlockTransformation::AdvancedProcessBlocks(inBlocks, xorBlocks, outBlocks, length, flags); diff --git a/speck-simd.cpp b/speck-simd.cpp index dd6e1cfb..d82842a2 100644 --- a/speck-simd.cpp +++ b/speck-simd.cpp @@ -43,7 +43,7 @@ # include #endif -#if defined(CRYPTOPP_POWER8_AVAILABLE) +#if defined(CRYPTOPP_POWER7_AVAILABLE) # include "ppc-simd.h" #endif @@ -842,9 +842,9 @@ inline void SPECK64_Dec_6_Blocks(__m128i &block0, __m128i &block1, #endif // CRYPTOPP_SSE41_AVAILABLE -// ***************************** Power8 ***************************** // +// ***************************** Power7 ***************************** // -#if defined(CRYPTOPP_POWER8_AVAILABLE) +#if defined(CRYPTOPP_POWER7_AVAILABLE) using CryptoPP::uint8x16_p; using CryptoPP::uint32x4_p; @@ -1072,7 +1072,7 @@ void SPECK64_Dec_6_Blocks(uint32x4_p &block0, uint32x4_p &block1, block5 = (uint32x4_p)vec_perm(x3, y3, m4); } -#endif // POWER8 +#endif // CRYPTOPP_POWER7_AVAILABLE // ***************************** Power8 ***************************** // @@ -1295,7 +1295,7 @@ void SPECK128_Dec_6_Blocks(uint32x4_p &block0, uint32x4_p &block1, block5 = (uint32x4_p)vec_perm(x3, y3, m4); } -#endif // POWER8 +#endif // CRYPTOPP_POWER8_AVAILABLE ANONYMOUS_NAMESPACE_END @@ -1371,23 +1371,27 @@ size_t SPECK128_Dec_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t ro } #endif // CRYPTOPP_SSSE3_AVAILABLE -// ***************************** Power8 ***************************** // +// ***************************** Power7 ***************************** // -#if defined(CRYPTOPP_POWER8_AVAILABLE) -size_t SPECK64_Enc_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, +#if defined(CRYPTOPP_POWER7_AVAILABLE) +size_t SPECK64_Enc_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) { return AdvancedProcessBlocks64_6x2_ALTIVEC(SPECK64_Enc_Block, SPECK64_Enc_6_Blocks, subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags); } -size_t SPECK64_Dec_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, +size_t SPECK64_Dec_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) { return AdvancedProcessBlocks64_6x2_ALTIVEC(SPECK64_Dec_Block, SPECK64_Dec_6_Blocks, subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags); } +#endif +// ***************************** Power8 ***************************** // + +#if defined(CRYPTOPP_POWER8_AVAILABLE) size_t SPECK128_Enc_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) { diff --git a/speck.cpp b/speck.cpp index da5d9afd..2915bb2e 100644 --- a/speck.cpp +++ b/speck.cpp @@ -200,13 +200,15 @@ extern size_t SPECK128_Dec_AdvancedProcessBlocks_SSSE3(const word64* subKeys, si const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); #endif +#if defined(CRYPTOPP_POWER7_AVAILABLE) +extern size_t SPECK64_Enc_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, + const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); + +extern size_t SPECK64_Dec_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t rounds, + const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); +#endif + #if defined(CRYPTOPP_POWER8_AVAILABLE) -extern size_t SPECK64_Enc_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, - const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); - -extern size_t SPECK64_Dec_AdvancedProcessBlocks_POWER8(const word32* subKeys, size_t rounds, - const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); - extern size_t SPECK128_Enc_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags); @@ -224,9 +226,9 @@ std::string SPECK64::Base::AlgorithmProvider() const if (HasNEON()) return "NEON"; #endif -#if (CRYPTOPP_POWER8_AVAILABLE) - if (HasPower8()) - return "Power8"; +#if (CRYPTOPP_POWER7_AVAILABLE) + if (HasPower7()) + return "Power7"; #endif return "C++"; } @@ -429,9 +431,9 @@ size_t SPECK64::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xor return SPECK64_Enc_AdvancedProcessBlocks_NEON(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif -#if (CRYPTOPP_POWER8_AVAILABLE) - if (HasPower8()) - return SPECK64_Enc_AdvancedProcessBlocks_POWER8(m_rkeys, (size_t)m_rounds, +#if (CRYPTOPP_POWER7_AVAILABLE) + if (HasPower7()) + return SPECK64_Enc_AdvancedProcessBlocks_POWER7(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif return BlockTransformation::AdvancedProcessBlocks(inBlocks, xorBlocks, outBlocks, length, flags); @@ -450,9 +452,9 @@ size_t SPECK64::Dec::AdvancedProcessBlocks(const byte *inBlocks, const byte *xor return SPECK64_Dec_AdvancedProcessBlocks_NEON(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif -#if (CRYPTOPP_POWER8_AVAILABLE) - if (HasPower8()) - return SPECK64_Dec_AdvancedProcessBlocks_POWER8(m_rkeys, (size_t)m_rounds, +#if (CRYPTOPP_POWER7_AVAILABLE) + if (HasPower7()) + return SPECK64_Dec_AdvancedProcessBlocks_POWER7(m_rkeys, (size_t)m_rounds, inBlocks, xorBlocks, outBlocks, length, flags); #endif return BlockTransformation::AdvancedProcessBlocks(inBlocks, xorBlocks, outBlocks, length, flags);