27 #if defined(CRYPTOPP_ALTIVEC_AVAILABLE) 31 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 36 #ifndef EXCEPTION_EXECUTE_HANDLER 37 # define EXCEPTION_EXECUTE_HANDLER 1 42 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 44 typedef void (*SigHandler)(int);
46 static jmp_buf s_jmpSIGILL;
47 static void SigIllHandler(
int)
49 longjmp(s_jmpSIGILL, 1);
52 #endif // Not CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 54 #if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) 55 bool CPU_ProbeAltivec()
57 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 59 #elif (CRYPTOPP_ALTIVEC_AVAILABLE) 60 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 64 volatile int result =
true;
66 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
67 if (oldHandler == SIG_ERR)
70 volatile sigset_t oldMask;
71 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
74 if (setjmp(s_jmpSIGILL))
78 const byte b1[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
79 const byte b2[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
82 const uint8x16_p v1 = (uint8x16_p)
VectorLoad(0, b1);
83 const uint8x16_p v2 = (uint8x16_p)
VectorLoad(0, b2);
84 const uint8x16_p v3 = (uint8x16_p)
VectorXor(v1, v2);
87 result = (0 == std::memcmp(b2, b3, 16));
90 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
91 signal(SIGILL, oldHandler);
96 #endif // CRYPTOPP_ALTIVEC_AVAILABLE 99 bool CPU_ProbePower7()
101 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 103 #elif (CRYPTOPP_POWER7_AVAILABLE) 104 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 108 volatile int result =
false;
110 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
111 if (oldHandler == SIG_ERR)
114 volatile sigset_t oldMask;
115 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
118 if (setjmp(s_jmpSIGILL))
122 byte b1[19] = {255, 255, 255, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, b2[17];
123 const uint8x16_p v1 = (uint8x16_p)
VectorLoad(0, b1+3);
126 result = (0 == std::memcmp(b1+3, b2+1, 16));
129 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
130 signal(SIGILL, oldHandler);
135 #endif // CRYPTOPP_POWER7_AVAILABLE 138 bool CPU_ProbePower8()
140 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 142 #elif (CRYPTOPP_POWER8_AVAILABLE) 143 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 147 volatile int result =
true;
149 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
150 if (oldHandler == SIG_ERR)
153 volatile sigset_t oldMask;
154 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
157 if (setjmp(s_jmpSIGILL))
161 byte b1[19] = {255, 255, 255, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, b2[17];
162 const uint8x16_p v1 = (uint8x16_p)
VectorLoad(0, b1+3);
165 result = (0 == std::memcmp(b1+3, b2+1, 16));
168 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
169 signal(SIGILL, oldHandler);
174 #endif // CRYPTOPP_POWER8_AVAILABLE 179 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 181 #elif (CRYPTOPP_POWER8_AVAILABLE) 182 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 186 volatile int result =
true;
188 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
189 if (oldHandler == SIG_ERR)
192 volatile sigset_t oldMask;
193 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
196 if (setjmp(s_jmpSIGILL))
200 byte key[16] = {0xA0, 0xFA, 0xFE, 0x17, 0x88, 0x54, 0x2c, 0xb1,
201 0x23, 0xa3, 0x39, 0x39, 0x2a, 0x6c, 0x76, 0x05};
202 byte state[16] = {0x19, 0x3d, 0xe3, 0xb3, 0xa0, 0xf4, 0xe2, 0x2b,
203 0x9a, 0xc6, 0x8d, 0x2a, 0xe9, 0xf8, 0x48, 0x08};
204 byte r[16] = {255}, z[16] = {};
206 uint8x16_p k = (uint8x16_p)
VectorLoad(0, key);
207 uint8x16_p s = (uint8x16_p)
VectorLoad(0, state);
214 result = (0 != std::memcmp(r, z, 16));
217 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
218 signal(SIGILL, oldHandler);
223 #endif // CRYPTOPP_ALTIVEC_AVAILABLE 226 bool CPU_ProbeSHA256()
228 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 230 #elif (CRYPTOPP_POWER8_AVAILABLE) 231 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 235 volatile int result =
false;
237 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
238 if (oldHandler == SIG_ERR)
241 volatile sigset_t oldMask;
242 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
245 if (setjmp(s_jmpSIGILL))
249 byte r[16], z[16] = {0};
250 uint8x16_p x = ((uint8x16_p){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
252 x = VectorSHA256<0,0>(x);
253 x = VectorSHA256<0,1>(x);
254 x = VectorSHA256<1,0>(x);
255 x = VectorSHA256<1,1>(x);
258 result = (0 == std::memcmp(r, z, 16));
261 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
262 signal(SIGILL, oldHandler);
267 #endif // CRYPTOPP_ALTIVEC_AVAILABLE 270 bool CPU_ProbeSHA512()
272 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 274 #elif (CRYPTOPP_POWER8_AVAILABLE) 275 # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) 279 volatile int result =
false;
281 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
282 if (oldHandler == SIG_ERR)
285 volatile sigset_t oldMask;
286 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
289 if (setjmp(s_jmpSIGILL))
293 byte r[16], z[16] = {0};
294 uint8x16_p x = ((uint8x16_p){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
296 x = VectorSHA512<0,0>(x);
297 x = VectorSHA512<0,1>(x);
298 x = VectorSHA512<1,0>(x);
299 x = VectorSHA512<1,1>(x);
302 result = (0 == std::memcmp(r, z, 16));
305 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
306 signal(SIGILL, oldHandler);
311 #endif // CRYPTOPP_POWER8_AVAILABLE 313 # endif // CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64 T1 VectorEncrypt(const T1 &state, const T2 &key)
One round of AES encryption.
T1 VectorEncryptLast(const T1 &state, const T2 &key)
Final round of AES encryption.
Library configuration file.
T1 VectorDecryptLast(const T1 &state, const T2 &key)
Final round of AES decryption.
Support functions for PowerPC and vector operations.
uint32x4_p VectorLoad(const byte src[16])
Loads a vector from a byte array.
T1 VectorXor(const T1 &vec1, const T2 &vec2)
XOR two vectors.
T1 VectorDecrypt(const T1 &state, const T2 &key)
One round of AES decryption.
Crypto++ library namespace.
void VectorStore(const T &src, byte dest[16])
Stores a vector to a byte array.