1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

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.
This commit is contained in:
Mounir IDRASSI
2022-02-13 18:41:18 +01:00
parent be5bcbf42f
commit d417b2806c
4 changed files with 32 additions and 7 deletions

View File

@@ -330,7 +330,9 @@ void DetectX86Features()
g_hasSSE42 = g_hasSSE2 && (cpuid1[2] & (1 << 20)); g_hasSSE42 = g_hasSSE2 && (cpuid1[2] & (1 << 20));
g_hasSSE41 = g_hasSSE2 && (cpuid1[2] & (1 << 19)); g_hasSSE41 = g_hasSSE2 && (cpuid1[2] & (1 << 19));
g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9)); g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));
#ifndef CRYPTOPP_DISABLE_AESNI
g_hasAESNI = g_hasSSE2 && (cpuid1[2] & (1<<25)); g_hasAESNI = g_hasSSE2 && (cpuid1[2] & (1<<25));
#endif
g_hasCLMUL = g_hasSSE2 && (cpuid1[2] & (1<<1)); g_hasCLMUL = g_hasSSE2 && (cpuid1[2] & (1<<1));
#if !defined (_UEFI) && ((defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE) #if !defined (_UEFI) && ((defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE)

View File

@@ -209,7 +209,9 @@ extern "C" {
#endif #endif
#define CRYPTOPP_CPUID_AVAILABLE #define CRYPTOPP_CPUID_AVAILABLE
#ifndef CRYPTOPP_DISABLE_AESNI
#define TC_AES_HW_CPU #define TC_AES_HW_CPU
#endif
// these should not be used directly // these should not be used directly
extern volatile int g_x86DetectionDone; extern volatile int g_x86DetectionDone;

View File

@@ -143,6 +143,7 @@ export PLATFORM_UNSUPPORTED := 0
export CPU_ARCH ?= unknown export CPU_ARCH ?= unknown
export SIMD_SUPPORTED := 0 export SIMD_SUPPORTED := 0
export DISABLE_AESNI ?= 0
ARCH ?= $(shell uname -m) ARCH ?= $(shell uname -m)
@@ -176,6 +177,9 @@ ifeq "$(origin NOSSE2)" "command line"
SIMD_SUPPORTED := 0 SIMD_SUPPORTED := 0
endif endif
ifeq "$(origin NOAESNI)" "command line"
DISABLE_AESNI := 1
endif
#------ Linux configuration ------ #------ Linux configuration ------
@@ -197,12 +201,17 @@ ifeq "$(shell uname -s)" "Linux"
CFLAGS += -msse2 CFLAGS += -msse2
CXXFLAGS += -msse2 CXXFLAGS += -msse2
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_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) 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" ifeq "$(GCC_GTEQ_440)" "1"
CFLAGS += -maes CFLAGS += -maes
CXXFLAGS += -maes CXXFLAGS += -maes
endif endif
endif
ifeq "$(GCC_GTEQ_430)" "1" ifeq "$(GCC_GTEQ_430)" "1"
ifeq "$(origin SSSE3)" "command line" ifeq "$(origin SSSE3)" "command line"
@@ -365,8 +374,16 @@ ifeq "$(shell uname -s)" "FreeBSD"
endif endif
ifeq "$(SIMD_SUPPORTED)" "1" ifeq "$(SIMD_SUPPORTED)" "1"
CFLAGS += -msse2 -maes CFLAGS += -msse2
CXXFLAGS += -msse2 -maes 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" ifeq "$(origin SSSE3)" "command line"
CFLAGS += -mssse3 CFLAGS += -mssse3

View File

@@ -47,12 +47,16 @@ ifeq "$(PLATFORM)" "MacOSX"
OBJSEX += ../Crypto/sha512_sse4.oo OBJSEX += ../Crypto/sha512_sse4.oo
else ifeq "$(CPU_ARCH)" "x86" else ifeq "$(CPU_ARCH)" "x86"
OBJS += ../Crypto/Aes_x86.o OBJS += ../Crypto/Aes_x86.o
ifeq "$(DISABLE_AESNI)" "0"
OBJS += ../Crypto/Aes_hw_cpu.o OBJS += ../Crypto/Aes_hw_cpu.o
endif
OBJS += ../Crypto/sha256-x86-nayuki.o OBJS += ../Crypto/sha256-x86-nayuki.o
OBJS += ../Crypto/sha512-x86-nayuki.o OBJS += ../Crypto/sha512-x86-nayuki.o
else ifeq "$(CPU_ARCH)" "x64" else ifeq "$(CPU_ARCH)" "x64"
OBJS += ../Crypto/Aes_x64.o OBJS += ../Crypto/Aes_x64.o
ifeq "$(DISABLE_AESNI)" "0"
OBJS += ../Crypto/Aes_hw_cpu.o OBJS += ../Crypto/Aes_hw_cpu.o
endif
OBJS += ../Crypto/Twofish_x64.o OBJS += ../Crypto/Twofish_x64.o
OBJS += ../Crypto/Camellia_x64.o OBJS += ../Crypto/Camellia_x64.o
OBJS += ../Crypto/Camellia_aesni_x64.o OBJS += ../Crypto/Camellia_aesni_x64.o