Make sure AES code is present when setting RANDOMX_FLAG_HARD_AES

This commit is contained in:
tevador 2019-10-09 22:06:04 +02:00
parent fc892fc5c0
commit abf2a5034e
2 changed files with 7 additions and 4 deletions

View file

@ -132,7 +132,7 @@ FORCE_INLINE rx_vec_f128 rx_set1_vec_f128(uint64_t x) {
#define rx_aesenc_vec_i128 _mm_aesenc_si128 #define rx_aesenc_vec_i128 _mm_aesenc_si128
#define rx_aesdec_vec_i128 _mm_aesdec_si128 #define rx_aesdec_vec_i128 _mm_aesdec_si128
#define HAVE_AES #define HAVE_AES 1
#endif //__AES__ #endif //__AES__
@ -303,7 +303,7 @@ FORCE_INLINE rx_vec_i128 rx_aesdec_vec_i128(rx_vec_i128 v, rx_vec_i128 rkey) {
__m128ll out = vrev((__m128i)__builtin_crypto_vncipher(_v,zero)); __m128ll out = vrev((__m128i)__builtin_crypto_vncipher(_v,zero));
return (rx_vec_i128)vec_xor((__m128i)out,rkey); return (rx_vec_i128)vec_xor((__m128i)out,rkey);
} }
#define HAVE_AES #define HAVE_AES 1
#endif //__CRYPTO__ #endif //__CRYPTO__
@ -455,7 +455,7 @@ FORCE_INLINE rx_vec_i128 rx_aesdec_vec_i128(rx_vec_i128 a, rx_vec_i128 key) {
return vaesimcq_u8(vaesdq_u8(a, zero)) ^ key; return vaesimcq_u8(vaesdq_u8(a, zero)) ^ key;
} }
#define HAVE_AES #define HAVE_AES 1
#endif #endif
@ -718,6 +718,9 @@ FORCE_INLINE rx_vec_i128 rx_aesenc_vec_i128(rx_vec_i128 v, rx_vec_i128 rkey) {
FORCE_INLINE rx_vec_i128 rx_aesdec_vec_i128(rx_vec_i128 v, rx_vec_i128 rkey) { FORCE_INLINE rx_vec_i128 rx_aesdec_vec_i128(rx_vec_i128 v, rx_vec_i128 rkey) {
throw std::runtime_error(platformError); throw std::runtime_error(platformError);
} }
#define HAVE_AES 0
#endif #endif
#ifdef RANDOMX_DEFAULT_FENV #ifdef RANDOMX_DEFAULT_FENV

View file

@ -42,7 +42,7 @@ extern "C" {
randomx_flags randomx_get_flags() { randomx_flags randomx_get_flags() {
randomx_flags flags = RANDOMX_HAVE_COMPILER ? RANDOMX_FLAG_JIT : RANDOMX_FLAG_DEFAULT; randomx_flags flags = RANDOMX_HAVE_COMPILER ? RANDOMX_FLAG_JIT : RANDOMX_FLAG_DEFAULT;
randomx::Cpu cpu; randomx::Cpu cpu;
if (cpu.hasAes()) { if (HAVE_AES && cpu.hasAes()) {
flags |= RANDOMX_FLAG_HARD_AES; flags |= RANDOMX_FLAG_HARD_AES;
} }
if (randomx_argon2_impl_avx2() != nullptr && cpu.hasAvx2()) { if (randomx_argon2_impl_avx2() != nullptr && cpu.hasAvx2()) {