From 0e3f4c40e3b1c5d8958148b079d4e9c6ae60ae69 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Thu, 18 Jun 2020 16:41:24 +0200 Subject: Windows: remove duplicated function to detect AES-NI support in CPU --- src/Common/Dlgcode.c | 2 +- src/Crypto/Aes_hw_cpu.h | 2 ++ src/Crypto/cpu.c | 22 ---------------------- src/Mount/Mount.c | 2 +- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index fe23deaf..4dee81b1 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -5999,7 +5999,7 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP uint32 driverConfig = ReadDriverConfigurationFlags(); - int isAesHwSupported = is_aes_hw_cpu_supported(); + int isAesHwSupported = HasAESNI(); SetDlgItemTextW (hwndDlg, IDC_HW_AES, (wstring (L" ") + (GetString (isAesHwSupported ? ((driverConfig & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? "UISTR_DISABLED" : "UISTR_YES") : "NOT_APPLICABLE_OR_NOT_AVAILABLE"))).c_str()); diff --git a/src/Crypto/Aes_hw_cpu.h b/src/Crypto/Aes_hw_cpu.h index 8977cbc0..b294e2ee 100644 --- a/src/Crypto/Aes_hw_cpu.h +++ b/src/Crypto/Aes_hw_cpu.h @@ -20,7 +20,9 @@ extern "C" { #endif +#if defined (TC_WINDOWS_BOOT) byte is_aes_hw_cpu_supported (); +#endif void aes_hw_cpu_enable_sse (); void aes_hw_cpu_decrypt (const byte *ks, byte *data); void aes_hw_cpu_decrypt_32_blocks (const byte *ks, byte *data); diff --git a/src/Crypto/cpu.c b/src/Crypto/cpu.c index 4aeb8d39..99b81700 100644 --- a/src/Crypto/cpu.c +++ b/src/Crypto/cpu.c @@ -422,28 +422,6 @@ void DetectX86Features() *((volatile int*)&g_x86DetectionDone) = 1; } -int is_aes_hw_cpu_supported () -{ - int bHasAESNI = 0; - uint32 cpuid[4]; - - if (CpuId(1, cpuid)) - { - if (cpuid[2] & (1<<25)) - bHasAESNI = 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 - // reference: http://artemonsecurity.com/vmde.pdf - if (!bHasAESNI && (cpuid[2] & (1<<31))) - { - bHasAESNI = Detect_MS_HyperV_AES (); - } -#endif - } - - return bHasAESNI; -} - void DisableCPUExtendedFeatures () { g_hasSSE2 = 0; diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 6b491c55..9dd5c479 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -11288,7 +11288,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM SetWindowTextW (GetDlgItem (hwndDlg, IDT_LIMIT_ENC_THREAD_POOL_NOTE), GetString("LIMIT_ENC_THREAD_POOL_NOTE")); - SetDlgItemTextW (hwndDlg, IDC_HW_AES_SUPPORTED_BY_CPU, (wstring (L" ") + (GetString (is_aes_hw_cpu_supported() ? "UISTR_YES" : "UISTR_NO"))).c_str()); + SetDlgItemTextW (hwndDlg, IDC_HW_AES_SUPPORTED_BY_CPU, (wstring (L" ") + (GetString (HasAESNI() ? "UISTR_YES" : "UISTR_NO"))).c_str()); ToHyperlink (hwndDlg, IDC_MORE_INFO_ON_HW_ACCELERATION); ToHyperlink (hwndDlg, IDC_MORE_INFO_ON_THREAD_BASED_PARALLELIZATION); -- cgit v1.2.3