From f40755fd7cb0c16ab37d016682d82e8fea4349b7 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 26 Sep 2016 13:42:02 +0200 Subject: 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). --- src/Setup/Wizard.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3