Add Octet suffix for vec_sld
We need to make room for packed shifts and rotatespull/748/head
parent
d656545875
commit
3c7bdf1a26
|
|
@ -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};
|
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));
|
c1 = VectorXor(c1, VMULL_10LE(c0, r));
|
||||||
c0 = VectorXor(c1, VectorShiftLeftOctet<8>(c0));
|
c0 = VectorXor(c1, VectorShiftLeftOctet<8>(c0));
|
||||||
c0 = VMULL_00LE(vec_sl(c0, m1), r);
|
c0 = VMULL_00LE(vec_sl(c0, m1), r);
|
||||||
|
|
|
||||||
14
ppc_simd.h
14
ppc_simd.h
|
|
@ -215,22 +215,22 @@ inline T VectorShiftLeftOctet(const T& vec)
|
||||||
/// \tparam T vector type
|
/// \tparam T vector type
|
||||||
/// \param vec the vector
|
/// \param vec the vector
|
||||||
/// \returns 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
|
/// concatenation of the zero vector and the source vector by the specified
|
||||||
/// number of bytes. The return vector is the same type as vec.
|
/// number of bytes. The return vector is the same type as vec.
|
||||||
/// \details On big endian machines VectorShiftRight() is <tt>vec_sld(a, z,
|
/// \details On big endian machines VectorShiftRightOctet() is <tt>vec_sld(a, z,
|
||||||
/// c)</tt>. On little endian machines VectorShiftRight() is translated to
|
/// c)</tt>. On little endian machines VectorShiftRightOctet() is translated to
|
||||||
/// <tt>vec_sld(z, a, 16-c)</tt>. You should always call the function as
|
/// <tt>vec_sld(z, a, 16-c)</tt>. You should always call the function as
|
||||||
/// if on a big endian machine as shown below.
|
/// if on a big endian machine as shown below.
|
||||||
/// <pre>
|
/// <pre>
|
||||||
/// uint8x16_p r1 = VectorLoad(ptr);
|
/// uint8x16_p r1 = VectorLoad(ptr);
|
||||||
/// uint8x16_p r5 = VectorShiftRight<12>(r1);
|
/// uint8x16_p r5 = VectorShiftRightOctet<12>(r1);
|
||||||
/// </pre>
|
/// </pre>
|
||||||
/// \sa <A HREF="https://stackoverflow.com/q/46341923/608639">Is vec_sld
|
/// \sa <A HREF="https://stackoverflow.com/q/46341923/608639">Is vec_sld
|
||||||
/// endian sensitive?</A> on Stack Overflow
|
/// endian sensitive?</A> on Stack Overflow
|
||||||
/// \since Crypto++ 6.0
|
/// \since Crypto++ 6.0
|
||||||
template <unsigned int C, class T>
|
template <unsigned int C, class T>
|
||||||
inline T VectorShiftRight(const T& vec)
|
inline T VectorShiftRightOctet(const T& vec)
|
||||||
{
|
{
|
||||||
const T zero = {0};
|
const T zero = {0};
|
||||||
if (C >= 16)
|
if (C >= 16)
|
||||||
|
|
@ -322,7 +322,7 @@ inline T VectorGetLow(const T& val)
|
||||||
//const T zero = {0};
|
//const T zero = {0};
|
||||||
//const uint8x16_p mask = {16,16,16,16, 16,16,16,16, 8,9,10,11, 12,13,14,15 };
|
//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 (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
|
/// \brief Extract a dword from a vector
|
||||||
|
|
@ -339,7 +339,7 @@ inline T VectorGetHigh(const T& val)
|
||||||
//const T zero = {0};
|
//const T zero = {0};
|
||||||
//const uint8x16_p mask = {16,16,16,16, 16,16,16,16, 0,1,2,3, 4,5,6,7 };
|
//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 (T)vec_perm(zero, val, mask);
|
||||||
return VectorShiftRight<8>(val);
|
return VectorShiftRightOctet<8>(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Compare two vectors
|
/// \brief Compare two vectors
|
||||||
|
|
|
||||||
12
validat1.cpp
12
validat1.cpp
|
|
@ -1145,7 +1145,7 @@ bool TestAltivecOps()
|
||||||
|
|
||||||
pass2 = (VectorEqual(val, VectorShiftLeftOctet<0>(val))) && pass2;
|
pass2 = (VectorEqual(val, VectorShiftLeftOctet<0>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
pass2 = (VectorEqual(val, VectorShiftRight<0>(val))) && pass2;
|
pass2 = (VectorEqual(val, VectorShiftRightOctet<0>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
|
|
||||||
uint8x16_p lsh1 = {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,
|
uint8x16_p lsh1 = {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,
|
||||||
|
|
@ -1155,7 +1155,7 @@ bool TestAltivecOps()
|
||||||
|
|
||||||
pass2 = (VectorEqual(lsh1, VectorShiftLeftOctet<1>(val))) && pass2;
|
pass2 = (VectorEqual(lsh1, VectorShiftLeftOctet<1>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
pass2 = (VectorEqual(rsh1, VectorShiftRight<1>(val))) && pass2;
|
pass2 = (VectorEqual(rsh1, VectorShiftRightOctet<1>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
|
|
||||||
uint8x16_p lsh15 = {0xff,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
|
uint8x16_p lsh15 = {0xff,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
|
||||||
|
|
@ -1165,7 +1165,7 @@ bool TestAltivecOps()
|
||||||
|
|
||||||
pass2 = (VectorEqual(lsh15, VectorShiftLeftOctet<15>(val))) && pass2;
|
pass2 = (VectorEqual(lsh15, VectorShiftLeftOctet<15>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
pass2 = (VectorEqual(rsh15, VectorShiftRight<15>(val))) && pass2;
|
pass2 = (VectorEqual(rsh15, VectorShiftRightOctet<15>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
|
|
||||||
uint8x16_p lsh16 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
|
uint8x16_p lsh16 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
|
||||||
|
|
@ -1175,7 +1175,7 @@ bool TestAltivecOps()
|
||||||
|
|
||||||
pass2 = (VectorEqual(lsh16, VectorShiftLeftOctet<16>(val))) && pass2;
|
pass2 = (VectorEqual(lsh16, VectorShiftLeftOctet<16>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
pass2 = (VectorEqual(rsh16, VectorShiftRight<16>(val))) && pass2;
|
pass2 = (VectorEqual(rsh16, VectorShiftRightOctet<16>(val))) && pass2;
|
||||||
CRYPTOPP_ASSERT(pass2);
|
CRYPTOPP_ASSERT(pass2);
|
||||||
|
|
||||||
if (!pass2)
|
if (!pass2)
|
||||||
|
|
@ -1199,10 +1199,10 @@ bool TestAltivecOps()
|
||||||
pass3 = VectorEqual(ex3, VectorGetHigh(ex1)) && pass3;
|
pass3 = VectorEqual(ex3, VectorGetHigh(ex1)) && pass3;
|
||||||
CRYPTOPP_ASSERT(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;
|
pass3 = VectorEqual(ex4, VectorGetLow(ex1)) && pass3;
|
||||||
CRYPTOPP_ASSERT(pass3);
|
CRYPTOPP_ASSERT(pass3);
|
||||||
uint8x16_p ex5 = VectorShiftRight<8>(ex1);
|
uint8x16_p ex5 = VectorShiftRightOctet<8>(ex1);
|
||||||
pass3 = VectorEqual(ex5, VectorGetHigh(ex1)) && pass3;
|
pass3 = VectorEqual(ex5, VectorGetHigh(ex1)) && pass3;
|
||||||
CRYPTOPP_ASSERT(pass3);
|
CRYPTOPP_ASSERT(pass3);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue