aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-02-09 09:38:17 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-02-09 09:38:17 +0000
commitc7e6b7739565951b06be42997bd97415faf35d4e (patch)
treeeb21f60f604336985d8360f1d365c8fa679f549a /src/crypto
parentcrypto: use software AES based on the MONERO_USE_SOFTWARE_AES env var (diff)
downloadmonero-c7e6b7739565951b06be42997bd97415faf35d4e.tar.xz
crypto: only check MONERO_USE_SOFTWARE_AES once
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/slow-hash.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c
index faaf127ce..4efa8af6c 100644
--- a/src/crypto/slow-hash.c
+++ b/src/crypto/slow-hash.c
@@ -189,12 +189,22 @@ STATIC INLINE void xor_blocks(uint8_t *a, const uint8_t *b)
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)
- return 0;
- if (!strcmp(env, "0") || !strcmp(env, "no"))
- return 0;
- return 1;
+ 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)