107 #ifndef CRYPTOPP_PPC_CRYPTO_H 108 #define CRYPTOPP_PPC_CRYPTO_H 113 #if defined(__ALTIVEC__) 114 # include <altivec.h> 124 #if defined(_AIX) && defined(_ARCH_PWR7) && defined(__xlC__) 132 #if defined(_AIX) && defined(_ARCH_PWR8) && defined(__xlC__) 133 # define __CRYPTO__ 1 141 #define CONST_V8_CAST(x) ((unsigned char*)(x)) 147 #define CONST_V32_CAST(x) ((unsigned int*)(x)) 153 #define CONST_V64_CAST(x) ((unsigned long long*)(x)) 159 #define NCONST_V8_CAST(x) ((unsigned char*)(x)) 165 #define NCONST_V32_CAST(x) ((unsigned int*)(x)) 171 #define NCONST_V64_CAST(x) ((unsigned long long*)(x)) 175 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 176 # pragma GCC diagnostic push 177 # pragma GCC diagnostic ignored "-Wdeprecated" 182 #if defined(__ALTIVEC__) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 200 #if defined(__VSX__) || defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 209 #endif // VSX or ARCH_PWR8 216 const uint32x4_p v = {0,0,0,0};
225 const uint32x4_p v = {1,1,1,1};
240 #if defined(CRYPTOPP_BIG_ENDIAN) 241 const uint8x16_p mask = {15,14,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0};
242 return (T)vec_perm(data, data, mask);
244 const uint8x16_p mask = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
245 return (T)vec_perm(data, data, mask);
261 #if defined(CRYPTOPP_LITTLE_ENDIAN) 262 const uint8x16_p mask = {15,14,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0};
263 return (T)vec_perm(data, data, mask);
281 #if defined(CRYPTOPP_BIG_ENDIAN) 282 const uint8x16_p mask = {15,14,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0};
283 return (T)vec_perm(data, data, mask);
307 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
318 return (uint32x4_p)vec_perm(low, high, perm);
338 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
349 return (uint32x4_p)vec_perm(low, high, perm);
371 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
373 CRYPTOPP_UNUSED(addr);
375 #if defined(_ARCH_PWR9) 395 inline uint32x4_p
VecLoad(
int off,
const byte src[16])
401 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
403 CRYPTOPP_UNUSED(addr);
405 #if defined(_ARCH_PWR9) 424 inline uint32x4_p
VecLoad(
const word32 src[4])
430 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
432 CRYPTOPP_UNUSED(addr);
434 #if defined(_ARCH_PWR9) 436 #elif defined(__VSX__) || defined(_ARCH_PWR8) 456 inline uint32x4_p
VecLoad(
int off,
const word32 src[4])
462 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
464 CRYPTOPP_UNUSED(addr);
466 #if defined(_ARCH_PWR9) 468 #elif defined(__VSX__) || defined(_ARCH_PWR8) 475 #if defined(__VSX__) || defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 490 inline uint64x2_p
VecLoad(
const word64 src[2])
496 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
498 CRYPTOPP_UNUSED(addr);
500 #if defined(_ARCH_PWR9) 502 #elif defined(__VSX__) || defined(_ARCH_PWR8) 524 inline uint64x2_p
VecLoad(
int off,
const word64 src[2])
530 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
532 CRYPTOPP_UNUSED(addr);
534 #if defined(_ARCH_PWR9) 536 #elif defined(__VSX__) || defined(_ARCH_PWR8) 544 #endif // VSX or ARCH_PWR8 562 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
564 CRYPTOPP_UNUSED(addr);
566 #if defined(_ARCH_PWR9) 590 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
592 CRYPTOPP_UNUSED(addr);
594 #if defined(_ARCH_PWR9) 617 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
619 CRYPTOPP_UNUSED(addr);
621 #if defined(_ARCH_PWR9) 623 #elif defined(__VSX__) || defined(_ARCH_PWR8) 647 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
649 CRYPTOPP_UNUSED(addr);
651 #if defined(_ARCH_PWR9) 653 #elif defined(__VSX__) || defined(_ARCH_PWR8) 660 #if defined(__VSX__) || defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 678 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
680 CRYPTOPP_UNUSED(addr);
682 #if defined(_ARCH_PWR9) 684 #elif defined(__VSX__) || defined(_ARCH_PWR8) 709 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
711 CRYPTOPP_UNUSED(addr);
713 #if defined(_ARCH_PWR9) 715 #elif defined(__VSX__) || defined(_ARCH_PWR8) 744 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src);
746 CRYPTOPP_UNUSED(addr);
748 #if defined(_ARCH_PWR9) 751 #elif defined(CRYPTOPP_BIG_ENDIAN) 772 inline uint32x4_p
VecLoadBE(
int off,
const byte src[16])
778 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(src)+off;
780 CRYPTOPP_UNUSED(addr);
782 #if defined(_ARCH_PWR9) 785 #elif defined(CRYPTOPP_BIG_ENDIAN) 816 uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
825 vec_ste((uint8x16_p) perm, 0, (
unsigned char*)
NCONST_V8_CAST(addr));
826 vec_ste((uint16x8_p) perm, 1, (
unsigned short*)
NCONST_V8_CAST(addr));
827 vec_ste((uint32x4_p) perm, 3, (
unsigned int*)
NCONST_V8_CAST(addr));
828 vec_ste((uint32x4_p) perm, 4, (
unsigned int*)
NCONST_V8_CAST(addr));
829 vec_ste((uint32x4_p) perm, 8, (
unsigned int*)
NCONST_V8_CAST(addr));
830 vec_ste((uint32x4_p) perm, 12, (
unsigned int*)
NCONST_V8_CAST(addr));
831 vec_ste((uint16x8_p) perm, 14, (
unsigned short*)
NCONST_V8_CAST(addr));
832 vec_ste((uint8x16_p) perm, 15, (
unsigned char*)
NCONST_V8_CAST(addr));
856 uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
865 vec_ste((uint8x16_p) perm, 0, (
unsigned char*)
NCONST_V8_CAST(addr));
866 vec_ste((uint16x8_p) perm, 1, (
unsigned short*)
NCONST_V8_CAST(addr));
867 vec_ste((uint32x4_p) perm, 3, (
unsigned int*)
NCONST_V8_CAST(addr));
868 vec_ste((uint32x4_p) perm, 4, (
unsigned int*)
NCONST_V8_CAST(addr));
869 vec_ste((uint32x4_p) perm, 8, (
unsigned int*)
NCONST_V8_CAST(addr));
870 vec_ste((uint32x4_p) perm, 12, (
unsigned int*)
NCONST_V8_CAST(addr));
871 vec_ste((uint16x8_p) perm, 14, (
unsigned short*)
NCONST_V8_CAST(addr));
872 vec_ste((uint8x16_p) perm, 15, (
unsigned char*)
NCONST_V8_CAST(addr));
897 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
899 CRYPTOPP_UNUSED(addr);
901 #if defined(_ARCH_PWR9) 924 inline void VecStore(
const T data,
int off, byte dest[16])
930 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
932 CRYPTOPP_UNUSED(addr);
934 #if defined(_ARCH_PWR9) 962 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
964 CRYPTOPP_UNUSED(addr);
966 #if defined(_ARCH_PWR9) 968 #elif defined(__VSX__) || defined(_ARCH_PWR8) 991 inline void VecStore(
const T data,
int off, word32 dest[4])
997 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
999 CRYPTOPP_UNUSED(addr);
1001 #if defined(_ARCH_PWR9) 1003 #elif defined(__VSX__) || defined(_ARCH_PWR8) 1032 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
1034 CRYPTOPP_UNUSED(addr);
1036 #if defined(_ARCH_PWR9) 1038 #elif defined(__VSX__) || defined(_ARCH_PWR8) 1063 inline void VecStore(
const T data,
int off, word64 dest[2])
1069 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
1071 CRYPTOPP_UNUSED(addr);
1073 #if defined(_ARCH_PWR9) 1075 #elif defined(__VSX__) || defined(_ARCH_PWR8) 1102 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
1104 CRYPTOPP_UNUSED(addr);
1106 #if defined(_ARCH_PWR9) 1133 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
1135 CRYPTOPP_UNUSED(addr);
1137 #if defined(_ARCH_PWR9) 1164 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
1166 CRYPTOPP_UNUSED(addr);
1168 #if defined(_ARCH_PWR9) 1170 #elif defined(__VSX__) || defined(_ARCH_PWR8) 1198 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
1200 CRYPTOPP_UNUSED(addr);
1202 #if defined(_ARCH_PWR9) 1204 #elif defined(__VSX__) || defined(_ARCH_PWR8) 1233 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
1235 CRYPTOPP_UNUSED(addr);
1237 #if defined(_ARCH_PWR9) 1239 #elif defined(CRYPTOPP_BIG_ENDIAN) 1269 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
1271 CRYPTOPP_UNUSED(addr);
1273 #if defined(_ARCH_PWR9) 1275 #elif defined(CRYPTOPP_BIG_ENDIAN) 1304 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest);
1306 CRYPTOPP_UNUSED(addr);
1308 #if defined(_ARCH_PWR9) 1310 #elif defined(CRYPTOPP_BIG_ENDIAN) 1340 const uintptr_t addr =
reinterpret_cast<uintptr_t
>(dest)+off;
1342 CRYPTOPP_UNUSED(addr);
1344 #if defined(_ARCH_PWR9) 1346 #elif defined(CRYPTOPP_BIG_ENDIAN) 1371 template <
class T1,
class T2>
1372 inline T1
VecAnd(
const T1 vec1,
const T2 vec2)
1374 return (T1)vec_and(vec1, (T1)vec2);
1390 template <
class T1,
class T2>
1391 inline T1
VecOr(
const T1 vec1,
const T2 vec2)
1393 return (T1)vec_or(vec1, (T1)vec2);
1409 template <
class T1,
class T2>
1410 inline T1
VecXor(
const T1 vec1,
const T2 vec2)
1412 return (T1)vec_xor(vec1, (T1)vec2);
1433 template <
class T1,
class T2>
1434 inline T1
VecAdd(
const T1 vec1,
const T2 vec2)
1436 return (T1)vec_add(vec1, (T1)vec2);
1451 template <
class T1,
class T2>
1452 inline T1
VecSub(
const T1 vec1,
const T2 vec2)
1454 return (T1)vec_sub(vec1, (T1)vec2);
1473 template <
class T1,
class T2>
1476 return (T1)vec_perm(vec, vec, (uint8x16_p)mask);
1491 template <
class T1,
class T2>
1492 inline T1
VecPermute(
const T1 vec1,
const T1 vec2,
const T2 mask)
1494 return (T1)vec_perm(vec1, (T1)vec2, (uint8x16_p)mask);
1523 template <
unsigned int C,
class T>
1539 #if defined(CRYPTOPP_BIG_ENDIAN) 1541 return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, R);
1543 enum { R=(16-C)&0xf };
1544 return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, R);
1570 template <
unsigned int C,
class T>
1586 #if defined(CRYPTOPP_BIG_ENDIAN) 1587 enum { R=(16-C)&0xf };
1588 return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, R);
1591 return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, R);
1609 template <
unsigned int C,
class T>
1612 #if defined(CRYPTOPP_BIG_ENDIAN) 1614 return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, R);
1616 enum { R=(16-C)&0xf };
1617 return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, R);
1634 template <
unsigned int C,
class T>
1637 #if defined(CRYPTOPP_BIG_ENDIAN) 1638 enum { R=(16-C)&0xf };
1639 return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, R);
1642 return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, R);
1655 template<
unsigned int C>
1658 const uint32x4_p m = {C, C, C, C};
1659 return vec_rl(vec, m);
1671 template<
unsigned int C>
1674 const uint32x4_p m = {32-C, 32-C, 32-C, 32-C};
1675 return vec_rl(vec, m);
1687 template<
unsigned int C>
1690 const uint32x4_p m = {C, C, C, C};
1691 return vec_sl(vec, m);
1703 template<
unsigned int C>
1706 const uint32x4_p m = {C, C, C, C};
1707 return vec_sr(vec, m);
1711 #if defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 1724 template<
unsigned int C>
1727 const uint64x2_p m = {C, C};
1728 return vec_rl(vec, m);
1742 template<
unsigned int C>
1745 const uint64x2_p m = {C, C};
1746 return vec_sl(vec, m);
1760 template<
unsigned int C>
1763 const uint64x2_p m = {64-C, 64-C};
1764 return vec_rl(vec, m);
1778 template<
unsigned int C>
1781 const uint64x2_p m = {C, C};
1782 return vec_sr(vec, m);
1803 return vec_mergel(vec1, vec2);
1817 return vec_mergeh(vec1, vec2);
1830 #if defined(_ARCH_PWR4) && defined(__GNUC__) 1831 return vec_splats(val);
1835 const word32 x[4] = {val};
1836 return vec_splat(
VecLoad(x),0);
1847 template <
unsigned int N>
1850 return vec_splat(val, N);
1853 #if defined(__VSX__) || defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 1863 return vec_splats((
unsigned long long)val);
1873 template <
unsigned int N>
1876 #if defined(__VSX__) || defined(_ARCH_PWR8) 1877 return vec_splat(val, N);
1882 const uint8x16_p m = {0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7};
1883 return vec_perm(val, val, m);
1887 const uint8x16_p m = {8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15};
1888 return vec_perm(val, val, m);
1908 #if defined(CRYPTOPP_BIG_ENDIAN) && (defined(__VSX__) || defined(_ARCH_PWR8)) 1910 return (T)
VecMergeLow((uint64x2_p)zero, (uint64x2_p)val);
1912 return VecShiftRightOctet<8>(VecShiftLeftOctet<8>(val));
1930 #if defined(CRYPTOPP_BIG_ENDIAN) && (defined(__VSX__) || defined(_ARCH_PWR8)) 1932 return (T)
VecMergeHigh((uint64x2_p)zero, (uint64x2_p)val);
1934 return VecShiftRightOctet<8>(val);
1948 return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, 8);
1967 template <
class T1,
class T2>
1970 return 1 == vec_all_eq((uint32x4_p)vec1, (uint32x4_p)vec2);
1984 template <
class T1,
class T2>
1987 return 0 == vec_all_eq((uint32x4_p)vec1, (uint32x4_p)vec2);
2007 inline uint32x4_p
VecAdd64(
const uint32x4_p& vec1,
const uint32x4_p& vec2)
2010 #if defined(_ARCH_PWR8) && !defined(CRYPTOPP_DEBUG) 2011 return (uint32x4_p)vec_add((uint64x2_p)vec1, (uint64x2_p)vec2);
2016 #if defined(CRYPTOPP_BIG_ENDIAN) 2017 const uint32x4_p zero = {0, 0, 0, 0};
2018 const uint32x4_p mask = {0, 1, 0, 1};
2020 const uint32x4_p zero = {0, 0, 0, 0};
2021 const uint32x4_p mask = {1, 0, 1, 0};
2024 uint32x4_p cy = vec_addc(vec1, vec2);
2025 uint32x4_p res = vec_add(vec1, vec2);
2026 cy = vec_and(mask, cy);
2027 cy = vec_sld (cy, zero, 4);
2028 return vec_add(res, cy);
2032 #if defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 2043 inline uint64x2_p
VecAdd64(
const uint64x2_p& vec1,
const uint64x2_p& vec2)
2046 const uint64x2_p res = vec_add(vec1, vec2);
2048 #if defined(CRYPTOPP_DEBUG) 2052 const uint32x4_p r =
VecAdd64(x, y);
2070 inline uint32x4_p
VecSub64(
const uint32x4_p& vec1,
const uint32x4_p& vec2)
2072 #if defined(_ARCH_PWR8) && !defined(CRYPTOPP_DEBUG) 2074 return (uint32x4_p)vec_sub((uint64x2_p)vec1, (uint64x2_p)vec2);
2079 #if defined(CRYPTOPP_BIG_ENDIAN) 2080 const uint32x4_p zero = {0, 0, 0, 0};
2081 const uint32x4_p mask = {0, 1, 0, 1};
2083 const uint32x4_p zero = {0, 0, 0, 0};
2084 const uint32x4_p mask = {1, 0, 1, 0};
2089 uint32x4_p bw = vec_subc(vec1, vec2);
2090 uint32x4_p res = vec_sub(vec1, vec2);
2091 bw = vec_andc(mask, bw);
2092 bw = vec_sld (bw, zero, 4);
2093 return vec_sub(res, bw);
2097 #if defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 2107 inline uint64x2_p
VecSub64(
const uint64x2_p& vec1,
const uint64x2_p& vec2)
2110 const uint64x2_p res = vec_sub(vec1, vec2);
2112 #if defined(CRYPTOPP_DEBUG) 2116 const uint32x4_p r =
VecSub64(x, y);
2134 template<
unsigned int C>
2137 #if defined(_ARCH_PWR8) && !defined(CRYPTOPP_DEBUG) 2139 return (uint32x4_p)VecRotateLeft<C>((
uint64x2_p)vec);
2142 enum {S64=C&63, S32=C&31, BR=(S64>=32)};
2145 uint32x4_p t1 = VecShiftLeft<S32>(vec);
2151 const uint8x16_p m = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
2156 const uint8x16_p m = {4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11};
2161 const uint8x16_p m = {4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11};
2166 const uint8x16_p m = {4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11};
2170 return vec_or(t1, t2);
2186 #if (CRYPTOPP_BIG_ENDIAN) 2187 const uint8x16_p m = { 1,2,3,4, 5,6,7,0, 9,10,11,12, 13,14,15,8 };
2190 const uint8x16_p m = { 7,0,1,2, 3,4,5,6, 15,8,9,10, 11,12,13,14 };
2195 #if defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 2205 template<
unsigned int C>
2209 const uint64x2_p res = VecRotateLeft<C>(vec);
2211 #if defined(CRYPTOPP_DEBUG) 2214 const uint32x4_p r = VecRotateLeft64<C>(x);
2232 template<
unsigned int C>
2235 #if defined(_ARCH_PWR8) && !defined(CRYPTOPP_DEBUG) 2237 return (uint32x4_p)VecRotateRight<C>((
uint64x2_p)vec);
2240 enum {S64=C&63, S32=C&31, BR=(S64>=32)};
2243 uint32x4_p t1 = VecShiftRight<S32>(vec);
2249 const uint8x16_p m = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
2254 const uint8x16_p m = {4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11};
2259 const uint8x16_p m = {4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11};
2264 const uint8x16_p m = {4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11};
2268 return vec_or(t1, t2);
2285 #if (CRYPTOPP_BIG_ENDIAN) 2286 const uint8x16_p m = { 7,0,1,2, 3,4,5,6, 15,8,9,10, 11,12,13,14 };
2289 const uint8x16_p m = { 1,2,3,4, 5,6,7,0, 9,10,11,12, 13,14,15,8 };
2294 #if defined(__VSX__) || defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 2304 template<
unsigned int C>
2308 const uint64x2_p res = VecRotateRight<C>(vec);
2310 #if defined(CRYPTOPP_DEBUG) 2313 const uint32x4_p r = VecRotateRight64<C>(x);
2335 template <
class T1,
class T2>
2338 return (T1)vec_and(vec1, (T1)vec2);
2354 template <
class T1,
class T2>
2357 return (T1)vec_or(vec1, (T1)vec2);
2373 template <
class T1,
class T2>
2376 return (T1)vec_xor(vec1, (T1)vec2);
2387 #if defined(_ARCH_PWR8) 2389 return (uint32x4_p)vec_splats((
unsigned long long)val);
2391 const word64 x[2] = {val,val};
2392 return (uint32x4_p)
VecLoad((
const word32*)x);
2403 template <
unsigned int N>
2406 #if defined(__VSX__) || defined(_ARCH_PWR8) 2407 return (uint32x4_p)vec_splat((uint64x2_p)val, N);
2412 const uint8x16_p m = {0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7};
2413 return (uint32x4_p)vec_perm(val, val, m);
2417 const uint8x16_p m = {8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15};
2418 return (uint32x4_p)vec_perm(val, val, m);
2423 #if defined(__VSX__) || defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 2429 template <
unsigned int N>
2432 return vec_splat(val, N);
2442 #if (defined(_ARCH_PWR8) && defined(__CRYPTO__)) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 2463 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2464 return __vpmsumw (a, b);
2465 #elif defined(__clang__) 2466 return __builtin_altivec_crypto_vpmsumw (a, b);
2468 return __builtin_crypto_vpmsumw (a, b);
2488 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2489 return __vpmsumd (a, b);
2490 #elif defined(__clang__) 2491 return __builtin_altivec_crypto_vpmsumd (a, b);
2493 return __builtin_crypto_vpmsumd (a, b);
2512 #if defined(CRYPTOPP_BIG_ENDIAN) 2534 #if defined(CRYPTOPP_BIG_ENDIAN) 2556 #if defined(CRYPTOPP_BIG_ENDIAN) 2578 #if defined(CRYPTOPP_BIG_ENDIAN) 2601 template <
class T1,
class T2>
2604 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2605 return (T1)__vcipher((uint8x16_p)state, (uint8x16_p)key);
2606 #elif defined(__clang__) 2607 return (T1)__builtin_altivec_crypto_vcipher((uint64x2_p)state, (uint64x2_p)key);
2608 #elif defined(__GNUC__) 2609 return (T1)__builtin_crypto_vcipher((uint64x2_p)state, (uint64x2_p)key);
2626 template <
class T1,
class T2>
2629 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2630 return (T1)__vcipherlast((uint8x16_p)state, (uint8x16_p)key);
2631 #elif defined(__clang__) 2632 return (T1)__builtin_altivec_crypto_vcipherlast((uint64x2_p)state, (uint64x2_p)key);
2633 #elif defined(__GNUC__) 2634 return (T1)__builtin_crypto_vcipherlast((uint64x2_p)state, (uint64x2_p)key);
2651 template <
class T1,
class T2>
2654 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2655 return (T1)__vncipher((uint8x16_p)state, (uint8x16_p)key);
2656 #elif defined(__clang__) 2657 return (T1)__builtin_altivec_crypto_vncipher((uint64x2_p)state, (uint64x2_p)key);
2658 #elif defined(__GNUC__) 2659 return (T1)__builtin_crypto_vncipher((uint64x2_p)state, (uint64x2_p)key);
2676 template <
class T1,
class T2>
2679 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2680 return (T1)__vncipherlast((uint8x16_p)state, (uint8x16_p)key);
2681 #elif defined(__clang__) 2682 return (T1)__builtin_altivec_crypto_vncipherlast((uint64x2_p)state, (uint64x2_p)key);
2683 #elif defined(__GNUC__) 2684 return (T1)__builtin_crypto_vncipherlast((uint64x2_p)state, (uint64x2_p)key);
2706 template <
int func,
int fmask,
class T>
2709 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2710 return (T)__vshasigmaw((uint32x4_p)data, func, fmask);
2711 #elif defined(__clang__) 2712 return (T)__builtin_altivec_crypto_vshasigmaw((uint32x4_p)data, func, fmask);
2713 #elif defined(__GNUC__) 2714 return (T)__builtin_crypto_vshasigmaw((uint32x4_p)data, func, fmask);
2731 template <
int func,
int fmask,
class T>
2734 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) 2735 return (T)__vshasigmad((uint64x2_p)data, func, fmask);
2736 #elif defined(__clang__) 2737 return (T)__builtin_altivec_crypto_vshasigmad((uint64x2_p)data, func, fmask);
2738 #elif defined(__GNUC__) 2739 return (T)__builtin_crypto_vshasigmad((uint64x2_p)data, func, fmask);
2747 #endif // __CRYPTO__ 2753 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 2754 # pragma GCC diagnostic pop 2757 #endif // CRYPTOPP_PPC_CRYPTO_H T VecSHA512(const T data)
SHA512 Sigma functions.
uint64x2_p VecIntelMultiply01(const uint64x2_p &a, const uint64x2_p &b)
Polynomial multiplication.
T1 VecDecryptLast(const T1 state, const T2 key)
Final round of AES decryption.
Utility functions for the Crypto++ library.
T VecShiftRightOctet(const T vec)
Shift a vector right.
#define NCONST_V8_CAST(x)
Cast array to vector pointer.
uint32x4_p VecPolyMultiply(const uint32x4_p &a, const uint32x4_p &b)
Polynomial multiplication.
uint32x4_p VecLoadAligned(const byte src[16])
Loads a vector from an aligned byte array.
T VecReverse(const T data)
Reverse bytes in a vector.
T1 VecAnd64(const T1 vec1, const T2 vec2)
AND two vectors as if uint64x2_p.
#define NCONST_V32_CAST(x)
Cast array to vector pointer.
T VecGetLow(const T val)
Extract a dword from a vector.
uint64x2_p VecIntelMultiply00(const uint64x2_p &a, const uint64x2_p &b)
Polynomial multiplication.
T1 VecSub(const T1 vec1, const T2 vec2)
Subtract two vectors.
uint32x4_p VecRotateRight64(const uint32x4_p vec)
Rotate a vector right as if uint64x2_p.
uint32x4_p VecAdd64(const uint32x4_p &vec1, const uint32x4_p &vec2)
Add two vectors as if uint64x2_p.
Library configuration file.
T1 VecOr64(const T1 vec1, const T2 vec2)
OR two vectors as if uint64x2_p.
T1 VecXor64(const T1 vec1, const T2 vec2)
XOR two vectors as if uint64x2_p.
T1 VecAdd(const T1 vec1, const T2 vec2)
Add two vectors.
T VecGetHigh(const T val)
Extract a dword from a vector.
uint32x4_p VecLoad_ALTIVEC(const byte src[16])
Loads a vector from a byte array.
uint32x4_p VecShiftLeft(const uint32x4_p vec)
Shift a vector left.
T1 VecPermute(const T1 vec, const T2 mask)
Permutes a vector.
uint32x4_p VecOne()
The 1 vector.
T VecSwapWords(const T vec)
Exchange high and low double words.
uint32x4_p VecRotateRight64< 8 >(const uint32x4_p vec)
Rotate a vector right as if uint64x2_p.
__vector unsigned int uint32x4_p
Vector of 32-bit elements.
bool VecNotEqual(const T1 vec1, const T2 vec2)
Compare two vectors.
T VecRotateLeftOctet(const T vec)
Rotate a vector left.
T VecMergeHigh(const T vec1, const T vec2)
Merge two vectors.
uint32x4_p VecRotateLeft64(const uint32x4_p vec)
Rotate a vector left as if uint64x2_p.
void VecStoreBE(const T data, byte dest[16])
Stores a vector to a byte array.
void VecStore(const T data, byte dest[16])
Stores a vector to a byte array.
uint32x4_p VecSub64(const uint32x4_p &vec1, const uint32x4_p &vec2)
Subtract two vectors as if uint64x2_p.
uint32x4_p VecSplatElement64(const uint32x4_p val)
Broadcast 64-bit element to a vector as if uint64x2_p.
T VecMergeLow(const T vec1, const T vec2)
Merge two vectors.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
uint32x4_p VecSplatElement(const uint32x4_p val)
Broadcast 32-bit element to a vector.
#define CONST_V32_CAST(x)
Cast array to vector pointer.
void VecStore_ALTIVEC(const T data, byte dest[16])
Stores a vector to a byte array.
T1 VecXor(const T1 vec1, const T2 vec2)
XOR two vectors.
uint32x4_p VecRotateLeft64< 8 >(const uint32x4_p vec)
Rotate a vector left as if uint64x2_p.
bool VecEqual(const T1 vec1, const T2 vec2)
Compare two vectors.
uint32x4_p VecZero()
The 0 vector.
__vector unsigned short uint16x8_p
Vector of 16-bit elements.
T VecReverseBE(const T data)
Reverse bytes in a vector.
uint32x4_p VecShiftRight(const uint32x4_p vec)
Shift a vector right.
uint32x4_p VecRotateLeft(const uint32x4_p vec)
Rotate a vector left.
uint32x4_p VecRotateRight(const uint32x4_p vec)
Rotate a vector right.
__vector unsigned long long uint64x2_p
Vector of 64-bit elements.
uint64x2_p VecIntelMultiply11(const uint64x2_p &a, const uint64x2_p &b)
Polynomial multiplication.
uint32x4_p VecLoadBE(const byte src[16])
Loads a vector from a byte array.
T1 VecOr(const T1 vec1, const T2 vec2)
OR two vectors.
#define CONST_V8_CAST(x)
Cast array to vector pointer.
T1 VecEncryptLast(const T1 state, const T2 key)
Final round of AES encryption.
void VecStoreAligned(const T data, byte dest[16])
Stores a vector to a byte array.
Crypto++ library namespace.
T1 VecDecrypt(const T1 state, const T2 key)
One round of AES decryption.
uint32x4_p VecLoad(const byte src[16])
Loads a vector from a byte array.
T VecRotateRightOctet(const T vec)
Rotate a vector right.
uint32x4_p VecSplatWord(word32 val)
Broadcast 32-bit word to a vector.
uint32x4_p VecSplatWord64(word64 val)
Broadcast 64-bit double word to a vector.
T VecReverseLE(const T data)
Reverse bytes in a vector.
__vector unsigned char uint8x16_p
Vector of 8-bit elements.
T VecShiftLeftOctet(const T vec)
Shift a vector left.
T1 VecAnd(const T1 vec1, const T2 vec2)
AND two vectors.
uint64x2_p VecIntelMultiply10(const uint64x2_p &a, const uint64x2_p &b)
Polynomial multiplication.
T1 VecEncrypt(const T1 state, const T2 key)
One round of AES encryption.
T VecSHA256(const T data)
SHA256 Sigma functions.