VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/cpu.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2017-07-04 11:19:53 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-07-04 12:28:17 +0200
commit88cc8a00f4a7fc34003b961c572d5a78462dd682 (patch)
treec34058cc9b899791f5b26a0c01955198cd0953d4 /src/Crypto/cpu.c
parent0358eb6c717cfe132bcec7fddeac14213ed8937c (diff)
downloadVeraCrypt-88cc8a00f4a7fc34003b961c572d5a78462dd682.tar.gz
VeraCrypt-88cc8a00f4a7fc34003b961c572d5a78462dd682.zip
Windows: correctly handle SEH exceptions during self-tests in order to disable CPU extended features in such case.
Diffstat (limited to 'src/Crypto/cpu.c')
-rw-r--r--src/Crypto/cpu.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/Crypto/cpu.c b/src/Crypto/cpu.c
index 7ec5b988..69a7fcff 100644
--- a/src/Crypto/cpu.c
+++ b/src/Crypto/cpu.c
@@ -200,10 +200,10 @@ static uint64 xgetbv()
#endif
}
-int g_x86DetectionDone = 0;
-int g_hasISSE = 0, g_hasSSE2 = 0, g_hasSSSE3 = 0, g_hasMMX = 0, g_hasAESNI = 0, g_hasCLMUL = 0, g_isP4 = 0;
-int g_hasAVX = 0, g_hasAVX2 = 0, g_hasBMI2 = 0, g_hasSSE42 = 0, g_hasSSE41 = 0, g_isIntel = 0, g_isAMD = 0;
-uint32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
+volatile int g_x86DetectionDone = 0;
+volatile int g_hasISSE = 0, g_hasSSE2 = 0, g_hasSSSE3 = 0, g_hasMMX = 0, g_hasAESNI = 0, g_hasCLMUL = 0, g_isP4 = 0;
+volatile int g_hasAVX = 0, g_hasAVX2 = 0, g_hasBMI2 = 0, g_hasSSE42 = 0, g_hasSSE41 = 0, g_isIntel = 0, g_isAMD = 0;
+volatile uint32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
VC_INLINE int IsIntel(const uint32 output[4])
{
@@ -381,5 +381,23 @@ int is_aes_hw_cpu_supported ()
return bHasAESNI;
}
+void DisableCPUExtendedFeatures ()
+{
+ g_hasSSE2 = 0;
+ g_hasISSE = 0;
+ g_hasMMX = 0;
+ g_hasSSE2 = 0;
+ g_hasISSE = 0;
+ g_hasMMX = 0;
+ g_hasAVX = 0;
+ g_hasAVX2 = 0;
+ g_hasBMI2 = 0;
+ g_hasSSE42 = 0;
+ g_hasSSE41 = 0;
+ g_hasSSSE3 = 0;
+ g_hasAESNI = 0;
+ g_hasCLMUL = 0;
+}
+
#endif