summaryrefslogtreecommitdiffstats
path: root/crypto/rand/rand_win.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/rand/rand_win.c')
-rw-r--r--crypto/rand/rand_win.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c
index ad5e3d116b..1d4420418e 100644
--- a/crypto/rand/rand_win.c
+++ b/crypto/rand/rand_win.c
@@ -118,6 +118,44 @@ size_t rand_pool_acquire_entropy(RAND_POOL *pool)
return rand_pool_entropy_available(pool);
}
+
+int rand_pool_add_nonce_data(RAND_POOL *pool)
+{
+ struct {
+ DWORD pid;
+ DWORD tid;
+ FILETIME time;
+ } data = { 0 };
+
+ /*
+ * Add process id, thread id, and a high resolution timestamp to
+ * ensure that the nonce is unique whith high probability for
+ * different process instances.
+ */
+ data.pid = GetCurrentProcessId();
+ data.tid = GetCurrentThreadId();
+ GetSystemTimeAsFileTime(&data.time);
+
+ return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
+}
+
+int rand_pool_add_additional_data(RAND_POOL *pool)
+{
+ struct {
+ DWORD tid;
+ LARGE_INTEGER time;
+ } data = { 0 };
+
+ /*
+ * Add some noise from the thread id and a high resolution timer.
+ * The thread id adds a little randomness if the drbg is accessed
+ * concurrently (which is the case for the <master> drbg).
+ */
+ data.tid = GetCurrentThreadId();
+ QueryPerformanceCounter(&data.time);
+ return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
+}
+
# if OPENSSL_API_COMPAT < 0x10100000L
int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
{