From 063a16fcd65aca3817d1eb1d91cefa5481d11d61 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 13 Sep 2019 11:16:21 -0700 Subject: [PATCH] Ensure SSE is enabled for Salsa20 on x64 --- node/Salsa20.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/node/Salsa20.hpp b/node/Salsa20.hpp index b80d11427..3b27187f7 100644 --- a/node/Salsa20.hpp +++ b/node/Salsa20.hpp @@ -15,13 +15,12 @@ #include "Constants.hpp" #include "Utils.hpp" -#if (!defined(ZT_SALSA20_SSE)) && (defined(__SSE2__) || defined(__WINDOWS__)) +#ifndef ZT_SALSA20_SSE +#if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__) || defined(_M_X64)) +#include #define ZT_SALSA20_SSE 1 #endif - -#ifdef ZT_SALSA20_SSE -#include -#endif // ZT_SALSA20_SSE +#endif namespace ZeroTier { @@ -31,14 +30,14 @@ namespace ZeroTier { class Salsa20 { public: - inline Salsa20() {} - inline ~Salsa20() { Utils::burn(&_state,sizeof(_state)); } + ZT_ALWAYS_INLINE Salsa20() {} + ZT_ALWAYS_INLINE ~Salsa20() { Utils::burn(&_state,sizeof(_state)); } /** * @param key 256-bit (32 byte) key * @param iv 64-bit initialization vector */ - inline Salsa20(const void *key,const void *iv) { init(key,iv); } + ZT_ALWAYS_INLINE Salsa20(const void *key,const void *iv) { init(key,iv); } /** * Initialize cipher