diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-09-26 13:42:02 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-10-17 18:40:17 +0200 |
commit | f40755fd7cb0c16ab37d016682d82e8fea4349b7 (patch) | |
tree | 047df1e137a605a2aeb7f351cac65c1f1082ac7e /src | |
parent | 3c09765208c82573155d1197386e593b93283896 (diff) | |
download | VeraCrypt-f40755fd7cb0c16ab37d016682d82e8fea4349b7.tar.gz VeraCrypt-f40755fd7cb0c16ab37d016682d82e8fea4349b7.zip |
Windows Setup: correct call to CryptAcquireContext to use memory only container for random generation and remove use of srand/rand (if CryptGenRandom fails which is very unlikely, we just use one color).
Diffstat (limited to 'src')
-rw-r--r-- | src/Setup/Wizard.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/Setup/Wizard.c b/src/Setup/Wizard.c index 8c0f058c..8bc64117 100644 --- a/src/Setup/Wizard.c +++ b/src/Setup/Wizard.c @@ -180,15 +180,11 @@ static int GetDonVal (int minVal, int maxVal) if (!prngInitialized) { - if (!CryptAcquireContext (&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0) - && !CryptAcquireContext (&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) + if (!CryptAcquireContext (&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) OsPrngAvailable = FALSE; else OsPrngAvailable = TRUE; - srand ((unsigned int) time (NULL)); - rand(); // Generate and discard the inital value, as it always appears to be somewhat non-random. - prngInitialized = TRUE; } @@ -197,7 +193,7 @@ static int GetDonVal (int minVal, int maxVal) return ((int) ((double) *((uint16 *) buffer) / (0xFFFF+1) * (maxVal + 1 - minVal)) + minVal); } else - return ((int) ((double) rand() / (RAND_MAX+1) * (maxVal + 1 - minVal)) + minVal); + return maxVal; } |