From 3c7bdf1a2681f227a2a91e9bdde37e3bd4313bf3 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 14 Nov 2018 23:32:26 -0500 Subject: [PATCH] Add Octet suffix for vec_sld We need to make room for packed shifts and rotates --- gcm_simd.cpp | 2 +- ppc_simd.h | 14 +++++++------- validat1.cpp | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gcm_simd.cpp b/gcm_simd.cpp index fe15f18f..2b054898 100644 --- a/gcm_simd.cpp +++ b/gcm_simd.cpp @@ -753,7 +753,7 @@ uint64x2_p GCM_Reduce_VMULL(uint64x2_p c0, uint64x2_p c1, uint64x2_p c2, uint64x { const uint64x2_p m1 = {1,1}, m63 = {63,63}; - c1 = VectorXor(c1, VectorShiftRight<8>(c0)); + c1 = VectorXor(c1, VectorShiftRightOctet<8>(c0)); c1 = VectorXor(c1, VMULL_10LE(c0, r)); c0 = VectorXor(c1, VectorShiftLeftOctet<8>(c0)); c0 = VMULL_00LE(vec_sl(c0, m1), r); diff --git a/ppc_simd.h b/ppc_simd.h index 6a4b7083..3b7bbcbc 100644 --- a/ppc_simd.h +++ b/ppc_simd.h @@ -215,22 +215,22 @@ inline T VectorShiftLeftOctet(const T& vec) /// \tparam T vector type /// \param vec the vector /// \returns vector -/// \details VectorShiftRight() returns a new vector after shifting the +/// \details VectorShiftRightOctet() returns a new vector after shifting the /// concatenation of the zero vector and the source vector by the specified /// number of bytes. The return vector is the same type as vec. -/// \details On big endian machines VectorShiftRight() is vec_sld(a, z, -/// c). On little endian machines VectorShiftRight() is translated to +/// \details On big endian machines VectorShiftRightOctet() is vec_sld(a, z, +/// c). On little endian machines VectorShiftRightOctet() is translated to /// vec_sld(z, a, 16-c). You should always call the function as /// if on a big endian machine as shown below. ///
 ///    uint8x16_p r1 = VectorLoad(ptr);
-///    uint8x16_p r5 = VectorShiftRight<12>(r1);
+///    uint8x16_p r5 = VectorShiftRightOctet<12>(r1);
 /// 
/// \sa Is vec_sld /// endian sensitive? on Stack Overflow /// \since Crypto++ 6.0 template -inline T VectorShiftRight(const T& vec) +inline T VectorShiftRightOctet(const T& vec) { const T zero = {0}; if (C >= 16) @@ -322,7 +322,7 @@ inline T VectorGetLow(const T& val) //const T zero = {0}; //const uint8x16_p mask = {16,16,16,16, 16,16,16,16, 8,9,10,11, 12,13,14,15 }; //return (T)vec_perm(zero, val, mask); - return VectorShiftRight<8>(VectorShiftLeftOctet<8>(val)); + return VectorShiftRightOctet<8>(VectorShiftLeftOctet<8>(val)); } /// \brief Extract a dword from a vector @@ -339,7 +339,7 @@ inline T VectorGetHigh(const T& val) //const T zero = {0}; //const uint8x16_p mask = {16,16,16,16, 16,16,16,16, 0,1,2,3, 4,5,6,7 }; //return (T)vec_perm(zero, val, mask); - return VectorShiftRight<8>(val); + return VectorShiftRightOctet<8>(val); } /// \brief Compare two vectors diff --git a/validat1.cpp b/validat1.cpp index cb32dad6..4432680f 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -1145,7 +1145,7 @@ bool TestAltivecOps() pass2 = (VectorEqual(val, VectorShiftLeftOctet<0>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(val, VectorShiftRight<0>(val))) && pass2; + pass2 = (VectorEqual(val, VectorShiftRightOctet<0>(val))) && pass2; CRYPTOPP_ASSERT(pass2); uint8x16_p lsh1 = {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, @@ -1155,7 +1155,7 @@ bool TestAltivecOps() pass2 = (VectorEqual(lsh1, VectorShiftLeftOctet<1>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(rsh1, VectorShiftRight<1>(val))) && pass2; + pass2 = (VectorEqual(rsh1, VectorShiftRightOctet<1>(val))) && pass2; CRYPTOPP_ASSERT(pass2); uint8x16_p lsh15 = {0xff,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, @@ -1165,7 +1165,7 @@ bool TestAltivecOps() pass2 = (VectorEqual(lsh15, VectorShiftLeftOctet<15>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(rsh15, VectorShiftRight<15>(val))) && pass2; + pass2 = (VectorEqual(rsh15, VectorShiftRightOctet<15>(val))) && pass2; CRYPTOPP_ASSERT(pass2); uint8x16_p lsh16 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, @@ -1175,7 +1175,7 @@ bool TestAltivecOps() pass2 = (VectorEqual(lsh16, VectorShiftLeftOctet<16>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(rsh16, VectorShiftRight<16>(val))) && pass2; + pass2 = (VectorEqual(rsh16, VectorShiftRightOctet<16>(val))) && pass2; CRYPTOPP_ASSERT(pass2); if (!pass2) @@ -1199,10 +1199,10 @@ bool TestAltivecOps() pass3 = VectorEqual(ex3, VectorGetHigh(ex1)) && pass3; CRYPTOPP_ASSERT(pass3); - uint8x16_p ex4 = VectorShiftRight<8>(VectorShiftLeftOctet<8>(ex1)); + uint8x16_p ex4 = VectorShiftRightOctet<8>(VectorShiftLeftOctet<8>(ex1)); pass3 = VectorEqual(ex4, VectorGetLow(ex1)) && pass3; CRYPTOPP_ASSERT(pass3); - uint8x16_p ex5 = VectorShiftRight<8>(ex1); + uint8x16_p ex5 = VectorShiftRightOctet<8>(ex1); pass3 = VectorEqual(ex5, VectorGetHigh(ex1)) && pass3; CRYPTOPP_ASSERT(pass3);