mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
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).
This commit is contained in:
@@ -180,15 +180,11 @@ static int GetDonVal (int minVal, int maxVal)
|
|||||||
|
|
||||||
if (!prngInitialized)
|
if (!prngInitialized)
|
||||||
{
|
{
|
||||||
if (!CryptAcquireContext (&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)
|
if (!CryptAcquireContext (&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
|
||||||
&& !CryptAcquireContext (&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET))
|
|
||||||
OsPrngAvailable = FALSE;
|
OsPrngAvailable = FALSE;
|
||||||
else
|
else
|
||||||
OsPrngAvailable = TRUE;
|
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;
|
prngInitialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +193,7 @@ static int GetDonVal (int minVal, int maxVal)
|
|||||||
return ((int) ((double) *((uint16 *) buffer) / (0xFFFF+1) * (maxVal + 1 - minVal)) + minVal);
|
return ((int) ((double) *((uint16 *) buffer) / (0xFFFF+1) * (maxVal + 1 - minVal)) + minVal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return ((int) ((double) rand() / (RAND_MAX+1) * (maxVal + 1 - minVal)) + minVal);
|
return maxVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user