VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Crypto.c8
-rw-r--r--src/Common/Tests.c41
2 files changed, 38 insertions, 11 deletions
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c
index 2035b7e3..c0e77922 100644
--- a/src/Common/Crypto.c
+++ b/src/Common/Crypto.c
@@ -1156,20 +1156,20 @@ static BOOL HwEncryptionDisabled = FALSE;
BOOL IsAesHwCpuSupported ()
{
+#ifdef TC_WINDOWS_BOOT_AES
static BOOL state = FALSE;
static BOOL stateValid = FALSE;
if (!stateValid)
{
-#ifdef TC_WINDOWS_BOOT_AES
state = is_aes_hw_cpu_supported() ? TRUE : FALSE;
-#else
- state = g_hasAESNI ? TRUE : FALSE;
-#endif
stateValid = TRUE;
}
return state && !HwEncryptionDisabled;
+#else
+ return (HasAESNI() && !HwEncryptionDisabled)? TRUE : FALSE;
+#endif
}
void EnableHwEncryption (BOOL enable)
diff --git a/src/Common/Tests.c b/src/Common/Tests.c
index cf30e4a1..77a7aa2e 100644
--- a/src/Common/Tests.c
+++ b/src/Common/Tests.c
@@ -1355,18 +1355,45 @@ BOOL AutoTestAlgorithms (void)
{
BOOL result = TRUE;
BOOL hwEncryptionEnabled = IsHwEncryptionEnabled();
+#if defined (_MSC_VER) && !defined (_UEFI)
+ BOOL exceptionCatched = FALSE;
+ __try
+ {
+#endif
+ EnableHwEncryption (FALSE);
- EnableHwEncryption (FALSE);
+ if (!DoAutoTestAlgorithms())
+ result = FALSE;
- if (!DoAutoTestAlgorithms())
- result = FALSE;
+ EnableHwEncryption (TRUE);
- EnableHwEncryption (TRUE);
+ if (!DoAutoTestAlgorithms())
+ result = FALSE;
- if (!DoAutoTestAlgorithms())
- result = FALSE;
+ EnableHwEncryption (hwEncryptionEnabled);
+#if defined (_MSC_VER) && !defined (_UEFI)
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+ exceptionCatched = TRUE;
+ }
- EnableHwEncryption (hwEncryptionEnabled);
+ if (exceptionCatched)
+ {
+ /* unexepected exception raised. Disable all CPU extended feature and try again */
+ EnableHwEncryption (hwEncryptionEnabled);
+ DisableCPUExtendedFeatures ();
+ __try
+ {
+ result = DoAutoTestAlgorithms();
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* exception still occuring. Report failure. */
+ result = FALSE;
+ }
+ }
+#endif
return result;
}