VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2022-02-13 18:41:18 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2022-02-13 18:42:27 +0100
commitd417b2806c88cf06f4f3baa0064d6b1f9f22037d (patch)
tree1b9371586cde72dfebf8d1ad2552552c33e93b91 /src
parentbe5bcbf42f4b2bdcc8307ee80fe1e954a4c481f2 (diff)
downloadVeraCrypt-d417b2806c88cf06f4f3baa0064d6b1f9f22037d.tar.gz
VeraCrypt-d417b2806c88cf06f4f3baa0064d6b1f9f22037d.zip
Linux/FreeBSD: Enable building without AESNI support by setting environment variable DISABLE_AESNI to 1 during build or passing NOAESNI=1 to make command
This comes following Github issue #892 and which should be solved thanks to this.
Diffstat (limited to 'src')
-rw-r--r--src/Crypto/cpu.c2
-rw-r--r--src/Crypto/cpu.h2
-rw-r--r--src/Makefile31
-rw-r--r--src/Volume/Volume.make4
4 files changed, 32 insertions, 7 deletions
diff --git a/src/Crypto/cpu.c b/src/Crypto/cpu.c
index 99b81700..27d62e43 100644
--- a/src/Crypto/cpu.c
+++ b/src/Crypto/cpu.c
@@ -329,9 +329,11 @@ void DetectX86Features()
g_hasBMI2 = g_hasSSE2 && (cpuid1[1] & (1 << 8));
g_hasSSE42 = g_hasSSE2 && (cpuid1[2] & (1 << 20));
g_hasSSE41 = g_hasSSE2 && (cpuid1[2] & (1 << 19));
g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));
+#ifndef CRYPTOPP_DISABLE_AESNI
g_hasAESNI = g_hasSSE2 && (cpuid1[2] & (1<<25));
+#endif
g_hasCLMUL = g_hasSSE2 && (cpuid1[2] & (1<<1));
#if !defined (_UEFI) && ((defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE)
// Hypervisor = bit 31 of ECX of CPUID leaf 0x1
diff --git a/src/Crypto/cpu.h b/src/Crypto/cpu.h
index 58729f32..1a3efcee 100644
--- a/src/Crypto/cpu.h
+++ b/src/Crypto/cpu.h
@@ -208,9 +208,11 @@ extern __m128i _mm_aesdeclast_si128(__m128i v, __m128i rkey);
extern "C" {
#endif
#define CRYPTOPP_CPUID_AVAILABLE
+#ifndef CRYPTOPP_DISABLE_AESNI
#define TC_AES_HW_CPU
+#endif
// these should not be used directly
extern volatile int g_x86DetectionDone;
extern volatile int g_hasSSE2;
diff --git a/src/Makefile b/src/Makefile
index eb87e6ea..05ea3f61 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -142,8 +142,9 @@ export PLATFORM_ARCH := "Unknown"
export PLATFORM_UNSUPPORTED := 0
export CPU_ARCH ?= unknown
export SIMD_SUPPORTED := 0
+export DISABLE_AESNI ?= 0
ARCH ?= $(shell uname -m)
ifneq (,$(filter i386 i486 i586 i686 x86,$(ARCH)))
@@ -175,8 +176,11 @@ endif
ifeq "$(origin NOSSE2)" "command line"
SIMD_SUPPORTED := 0
endif
+ifeq "$(origin NOAESNI)" "command line"
+ DISABLE_AESNI := 1
+endif
#------ Linux configuration ------
ifeq "$(shell uname -s)" "Linux"
@@ -196,13 +200,18 @@ ifeq "$(shell uname -s)" "Linux"
ifeq "$(SIMD_SUPPORTED)" "1"
CFLAGS += -msse2
CXXFLAGS += -msse2
- GCC_GTEQ_440 := $(shell expr `$(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/' -e 's/^[0-9]\{1,2\}$$/&0000/'` \>= 40400)
- GCC_GTEQ_430 := $(shell expr `$(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/' -e 's/^[0-9]\{1,2\}$$/&0000/'` \>= 40300)
- ifeq "$(GCC_GTEQ_440)" "1"
- CFLAGS += -maes
- CXXFLAGS += -maes
+ ifeq "$(DISABLE_AESNI)" "1"
+ CFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI
+ CXXFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI
+ else
+ GCC_GTEQ_440 := $(shell expr `$(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/' -e 's/^[0-9]\{1,2\}$$/&0000/'` \>= 40400)
+ GCC_GTEQ_430 := $(shell expr `$(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/' -e 's/^[0-9]\{1,2\}$$/&0000/'` \>= 40300)
+ ifeq "$(GCC_GTEQ_440)" "1"
+ CFLAGS += -maes
+ CXXFLAGS += -maes
+ endif
endif
ifeq "$(GCC_GTEQ_430)" "1"
ifeq "$(origin SSSE3)" "command line"
@@ -364,10 +373,18 @@ ifeq "$(shell uname -s)" "FreeBSD"
WXCONFIG_CXXFLAGS += -fpie -fPIC
endif
ifeq "$(SIMD_SUPPORTED)" "1"
- CFLAGS += -msse2 -maes
- CXXFLAGS += -msse2 -maes
+ CFLAGS += -msse2
+ CXXFLAGS += -msse2
+
+ ifeq "$(DISABLE_AESNI)" "1"
+ CFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI
+ CXXFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI
+ else
+ CFLAGS += -maes
+ CXXFLAGS += -maes
+ endif
ifeq "$(origin SSSE3)" "command line"
CFLAGS += -mssse3
CXXFLAGS += -mssse3
diff --git a/src/Volume/Volume.make b/src/Volume/Volume.make
index 224eff66..a7f9ef0a 100644
--- a/src/Volume/Volume.make
+++ b/src/Volume/Volume.make
@@ -46,14 +46,18 @@ ifeq "$(PLATFORM)" "MacOSX"
OBJSEX += ../Crypto/sha512_avx2.oo
OBJSEX += ../Crypto/sha512_sse4.oo
else ifeq "$(CPU_ARCH)" "x86"
OBJS += ../Crypto/Aes_x86.o
+ifeq "$(DISABLE_AESNI)" "0"
OBJS += ../Crypto/Aes_hw_cpu.o
+endif
OBJS += ../Crypto/sha256-x86-nayuki.o
OBJS += ../Crypto/sha512-x86-nayuki.o
else ifeq "$(CPU_ARCH)" "x64"
OBJS += ../Crypto/Aes_x64.o
+ifeq "$(DISABLE_AESNI)" "0"
OBJS += ../Crypto/Aes_hw_cpu.o
+endif
OBJS += ../Crypto/Twofish_x64.o
OBJS += ../Crypto/Camellia_x64.o
OBJS += ../Crypto/Camellia_aesni_x64.o
OBJS += ../Crypto/sha512-x64-nayuki.o