VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-10-30 08:45:01 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-10-30 08:53:03 +0100
commit5ecff99edc9c342987ef59156c2358a4c24ce9b5 (patch)
tree96c5db33afa9394231f91669b6e2de4873892a40 /src/Crypto
parent7a35ecb154fc979d46dea8d97d0ad97fd4ae4140 (diff)
downloadVeraCrypt-5ecff99edc9c342987ef59156c2358a4c24ce9b5.tar.gz
VeraCrypt-5ecff99edc9c342987ef59156c2358a4c24ce9b5.zip
Add check for buggy RDRAND (AMD Ryzen CPU case) even if we always use RDSEED instead of RDRAND when RDSEED is available (which is the case on modern CPUs)
Diffstat (limited to 'src/Crypto')
-rw-r--r--src/Crypto/cpu.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Crypto/cpu.c b/src/Crypto/cpu.c
index 62574983..33a9815e 100644
--- a/src/Crypto/cpu.c
+++ b/src/Crypto/cpu.c
@@ -2,6 +2,7 @@
#include "cpu.h"
#include "misc.h"
+#include "rdrand.h"
#ifndef EXCEPTION_EXECUTE_HANDLER
#define EXCEPTION_EXECUTE_HANDLER 1
@@ -387,6 +388,18 @@ void DetectX86Features()
}
}
+ /* Add check fur buggy RDRAND (AMD Ryzen case) even if we always use RDSEED instead of RDRAND when RDSEED available */
+ if (g_hasRDRAND)
+ {
+ if ( RDRAND_getBytes ((unsigned char*) cpuid, sizeof (cpuid))
+ && (cpuid[0] == 0xFFFFFFFF) && (cpuid[1] == 0xFFFFFFFF)
+ && (cpuid[2] == 0xFFFFFFFF) && (cpuid[3] == 0xFFFFFFFF)
+ )
+ {
+ g_hasRDRAND = 0;
+ }
+ }
+
if (!g_cacheLineSize)
g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;