Skip to content

Commit 761a976

Browse files
committed
Add support for MemUse Entropy on Windows.
1 parent 8c012b5 commit 761a976

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

wolfcrypt/src/random.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,29 @@ static void Entropy_StopThread(void)
983983
}
984984
}
985985
/* end if defined(HAVE_PTHREAD) */
986+
987+
#elif defined(_WIN32) /* USE_WINDOWS_API */
988+
989+
/* Get the high resolution time counter.
990+
*
991+
* @return 64-bit time that is the nanoseconds of current time.
992+
*/
993+
static WC_INLINE word64 Entropy_TimeHiRes(void)
994+
{
995+
static int init = 0;
996+
static LARGE_INTEGER freq;
997+
LARGE_INTEGER count;
998+
999+
if (!init) {
1000+
QueryPerformanceFrequency(&freq);
1001+
init = 1;
1002+
}
1003+
1004+
QueryPerformanceCounter(&count);
1005+
1006+
return (word64)(count.QuadPart / (freq.QuadPart / 1000 / 1000));
1007+
}
1008+
9861009
#else
9871010

9881011
#error "No high precision time available for MemUse Entropy."
@@ -1283,7 +1306,7 @@ static int Entropy_HealthTest_Proportion(byte noise)
12831306
}
12841307
else {
12851308
/* Get first value in queue - value to test. */
1286-
byte val = prop_samples[prop_first];
1309+
byte val = (byte)prop_samples[prop_first];
12871310
/* Store new sample in queue. */
12881311
prop_samples[prop_last] = noise;
12891312
/* Update first index now that we have removed in from the queue. */

0 commit comments

Comments
 (0)