summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--make-freebsd.mk21
-rw-r--r--make-linux.mk21
-rw-r--r--make-mac.mk3
-rw-r--r--node/Salsa20.hpp6
-rw-r--r--selftest.cpp6
5 files changed, 12 insertions, 45 deletions
diff --git a/make-freebsd.mk b/make-freebsd.mk
index 2832136e..6a0f354d 100644
--- a/make-freebsd.mk
+++ b/make-freebsd.mk
@@ -8,27 +8,6 @@ LIBS=
include objects.mk
OBJS+=osdep/BSDEthernetTap.o
-# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
-MACHINE=$(shell uname -m)
-ifeq ($(MACHINE),x86_64)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),amd64)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),i686)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),i586)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),i386)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),x86)
- DEFS+=-DZT_SALSA20_SSE
-endif
-
# "make official" is a shortcut for this
ifeq ($(ZT_OFFICIAL_RELEASE),1)
ZT_AUTO_UPDATE=1
diff --git a/make-linux.mk b/make-linux.mk
index 6b92bfaa..892b40b6 100644
--- a/make-linux.mk
+++ b/make-linux.mk
@@ -9,27 +9,6 @@ LIBS=
include objects.mk
OBJS+=osdep/LinuxEthernetTap.o
-# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
-MACHINE=$(shell uname -m)
-ifeq ($(MACHINE),x86_64)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),amd64)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),i686)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),i586)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),i386)
- DEFS+=-DZT_SALSA20_SSE
-endif
-ifeq ($(MACHINE),x86)
- DEFS+=-DZT_SALSA20_SSE
-endif
-
# "make official" is a shortcut for this
ifeq ($(ZT_OFFICIAL_RELEASE),1)
ZT_AUTO_UPDATE=1
diff --git a/make-mac.mk b/make-mac.mk
index 7d730ae5..48bfdd79 100644
--- a/make-mac.mk
+++ b/make-mac.mk
@@ -31,9 +31,6 @@ ifeq ($(ZT_ENABLE_NETWORK_CONTROLLER),1)
OBJS+=controller/SqliteNetworkController.o
endif
-# Enable SSE-optimized Salsa20 -- all Intel macs support SSE2
-DEFS+=-DZT_SALSA20_SSE
-
# Debug mode -- dump trace output, build binary with -g
ifeq ($(ZT_DEBUG),1)
DEFS+=-DZT_TRACE
diff --git a/node/Salsa20.hpp b/node/Salsa20.hpp
index 0c1f3be4..9631a6db 100644
--- a/node/Salsa20.hpp
+++ b/node/Salsa20.hpp
@@ -7,10 +7,16 @@
#ifndef ZT_SALSA20_HPP
#define ZT_SALSA20_HPP
+#include <stdio.h>
#include <stdint.h>
+#include <stdlib.h>
#include "Constants.hpp"
+#if (!defined(ZT_SALSA20_SSE)) && (defined(__SSE2__) || defined(__WINDOWS__))
+#define ZT_SALSA20_SSE 1
+#endif
+
#ifdef ZT_SALSA20_SSE
#include <emmintrin.h>
#endif // ZT_SALSA20_SSE
diff --git a/selftest.cpp b/selftest.cpp
index a0b3c951..27c81c25 100644
--- a/selftest.cpp
+++ b/selftest.cpp
@@ -187,6 +187,12 @@ static int testCrypto()
}
std::cout << "PASS" << std::endl;
+#ifdef ZT_SALSA20_SSE
+ std::cout << "[crypto] Salsa20 SSE: ENABLED" << std::endl;
+#else
+ std::cout << "[crypto] Salsa20 SSE: DISABLED" << std::endl;
+#endif
+
std::cout << "[crypto] Benchmarking Salsa20/12... "; std::cout.flush();
{
unsigned char *bb = (unsigned char *)::malloc(1234567);