diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-02-13 19:51:30 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-02-13 19:51:30 +0200 |
commit | 999992a64b53c7834b5650ea1aaa28bb74d42e36 (patch) | |
tree | 41229ea34e01e4f46f50df2b2cbddeba592f44c2 /src | |
parent | Merge pull request #651 (diff) | |
parent | crypto: only check MONERO_USE_SOFTWARE_AES once (diff) | |
download | monero-999992a64b53c7834b5650ea1aaa28bb74d42e36.tar.xz |
Merge pull request #652
c7e6b77 crypto: only check MONERO_USE_SOFTWARE_AES once (moneromooo-monero)
74aef21 crypto: use software AES based on the MONERO_USE_SOFTWARE_AES env var (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/crypto/slow-hash.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 903a3792f..4efa8af6c 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -187,6 +187,26 @@ STATIC INLINE void xor_blocks(uint8_t *a, const uint8_t *b) * @return true if the CPU supports AES, false otherwise */ +STATIC INLINE int force_software_aes(void) +{ + static int use = -1; + + if (use != -1) + return use; + + const char *env = getenv("MONERO_USE_SOFTWARE_AES"); + if (!env) { + use = 0; + } + else if (!strcmp(env, "0") || !strcmp(env, "no")) { + use = 0; + } + else { + use = 1; + } + return use; +} + STATIC INLINE int check_aes_hw(void) { int cpuid_results[4]; @@ -509,7 +529,7 @@ void cn_slow_hash(const void *data, size_t length, char *hash) size_t i, j; uint64_t *p = NULL; oaes_ctx *aes_ctx; - int useAes = check_aes_hw(); + int useAes = !force_software_aes() && check_aes_hw(); static void (*const extra_hashes[4])(const void *, size_t, char *) = { |