VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Random.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-10-03 17:25:57 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-10-03 17:32:39 (GMT)
commit1298f83aa49948962b57dc302cc868130b60c0b5 (patch)
tree5442598fd9e56971f4b40504c937546d31f37752 /src/Common/Random.c
parent9f91c47bd22e5753d62e9c19f05f3ad79672d008 (diff)
downloadVeraCrypt-1298f83aa49948962b57dc302cc868130b60c0b5.zip
VeraCrypt-1298f83aa49948962b57dc302cc868130b60c0b5.tar.gz
Windows: Add function RandinitWithCheck to detect if random generator was already initialized before our call or not
Diffstat (limited to 'src/Common/Random.c')
-rw-r--r--src/Common/Random.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Common/Random.c b/src/Common/Random.c
index a2da77f..09c55bf 100644
--- a/src/Common/Random.c
+++ b/src/Common/Random.c
@@ -94,14 +94,21 @@ HCRYPTPROV hCryptProv;
/* Init the random number generator, setup the hooks, and start the thread */
-int Randinit ()
+int RandinitWithCheck ( int* pAlreadyInitialized)
{
DWORD dwLastError = ERROR_SUCCESS;
if (GetMaxPkcs5OutSize() > RNG_POOL_SIZE)
TC_THROW_FATAL_EXCEPTION;
if(bRandDidInit)
+ {
+ if (pAlreadyInitialized)
+ *pAlreadyInitialized = 1;
return 0;
+ }
+
+ if (pAlreadyInitialized)
+ *pAlreadyInitialized = 0;
InitializeCriticalSection (&critRandProt);
@@ -153,6 +160,11 @@ error:
return 1;
}
+int Randinit ()
+{
+ return RandinitWithCheck (NULL);
+}
+
/* Close everything down, including the thread which is closed down by
setting a flag which eventually causes the thread function to exit */
void RandStop (BOOL freePool)