12 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 17 #if defined(_ARCH_PWR8) || defined(__CRYPTO__) 22 extern const char PPC_POWER8_FNAME[] = __FILE__;
28 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 30 typedef void (*SigHandler)(int);
32 static jmp_buf s_jmpSIGILL;
33 static void SigIllHandler(
int)
35 longjmp(s_jmpSIGILL, 1);
38 #endif // CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 40 #if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) 42 bool CPU_ProbePower8()
44 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 46 #elif (_ARCH_PWR8) && defined(CRYPTOPP_POWER8_AVAILABLE) 47 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 51 volatile int result =
true;
53 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
54 if (oldHandler == SIG_ERR)
57 volatile sigset_t oldMask;
58 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
60 signal(SIGILL, oldHandler);
64 if (setjmp(s_jmpSIGILL))
70 word64 w1[2] = {x, x}, w2[2] = {4, 6}, w3[2];
73 #if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__)) || defined(__clang__) 74 const uint64x2_p v1 = vec_xl(0, (
unsigned long long*)w1);
75 const uint64x2_p v2 = vec_xl(0, (
unsigned long long*)w2);
77 vec_xst(v3, 0, (
unsigned long long*)w3);
86 result = (w3[0] == 3 && w3[1] == 5);
89 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
90 signal(SIGILL, oldHandler);
100 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 102 #elif (__CRYPTO__) && defined(CRYPTOPP_POWER8_AES_AVAILABLE) 103 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 107 volatile int result =
true;
109 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
110 if (oldHandler == SIG_ERR)
113 volatile sigset_t oldMask;
114 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
116 signal(SIGILL, oldHandler);
120 if (setjmp(s_jmpSIGILL))
124 byte key[16] = {0xA0, 0xFA, 0xFE, 0x17, 0x88, 0x54, 0x2c, 0xb1,
125 0x23, 0xa3, 0x39, 0x39, 0x2a, 0x6c, 0x76, 0x05};
126 byte state[16] = {0x19, 0x3d, 0xe3, 0xb3, 0xa0, 0xf4, 0xe2, 0x2b,
127 0x9a, 0xc6, 0x8d, 0x2a, 0xe9, 0xf8, 0x48, 0x08};
128 byte r[16] = {255}, z[16] = {};
138 result = (0 != std::memcmp(r, z, 16));
141 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
142 signal(SIGILL, oldHandler);
150 bool CPU_ProbeSHA256()
152 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 154 #elif (__CRYPTO__) && defined(CRYPTOPP_POWER8_SHA_AVAILABLE) 155 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 159 volatile int result =
false;
161 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
162 if (oldHandler == SIG_ERR)
165 volatile sigset_t oldMask;
166 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
168 signal(SIGILL, oldHandler);
172 if (setjmp(s_jmpSIGILL))
176 byte r[16], z[16] = {0};
177 uint8x16_p x = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
179 x = VecSHA256<0,0>(x);
180 x = VecSHA256<0,0xf>(x);
181 x = VecSHA256<1,0>(x);
182 x = VecSHA256<1,0xf>(x);
185 result = (0 == std::memcmp(r, z, 16));
188 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
189 signal(SIGILL, oldHandler);
194 #endif // CRYPTOPP_ALTIVEC_AVAILABLE 197 bool CPU_ProbeSHA512()
199 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 201 #elif (__CRYPTO__) && defined(CRYPTOPP_POWER8_SHA_AVAILABLE) 202 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 206 volatile int result =
false;
208 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
209 if (oldHandler == SIG_ERR)
212 volatile sigset_t oldMask;
213 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
215 signal(SIGILL, oldHandler);
219 if (setjmp(s_jmpSIGILL))
223 byte r[16], z[16] = {0};
224 uint8x16_p x = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
226 x = VecSHA512<0,0>(x);
227 x = VecSHA512<0,0xf>(x);
228 x = VecSHA512<1,0>(x);
229 x = VecSHA512<1,0xf>(x);
232 result = (0 == std::memcmp(r, z, 16));
235 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
236 signal(SIGILL, oldHandler);
241 #endif // CRYPTOPP_POWER8_AVAILABLE 244 #endif // PPC32 or PPC64 T1 VecDecryptLast(const T1 state, const T2 key)
Final round of AES decryption.
#define W64LIT(x)
Declare an unsigned word64.
Library configuration file.
unsigned long long word64
64-bit unsigned datatype
Support functions for PowerPC and vector operations.
void VecStore(const T data, byte dest[16])
Stores a vector to a byte array.
unsigned char byte
8-bit unsigned datatype
__vector unsigned long long uint64x2_p
Vector of 64-bit elements.
T1 VecEncryptLast(const T1 state, const T2 key)
Final round of AES encryption.
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.
__vector unsigned char uint8x16_p
Vector of 8-bit elements.
T1 VecEncrypt(const T1 state, const T2 key)
One round of AES encryption.