Botan 3.13.0
Crypto and TLS for C&
es_win32.cpp
Go to the documentation of this file.
1/*
2* (C) 1999-2009,2016,2020 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/es_win32.h>
8
9#include <botan/rng.h>
10
11#define NOMINMAX 1
12#define _WINSOCKAPI_ // stop windows.h including winsock.h
13#include <windows.h>
14
15namespace Botan {
16
18 rng.add_entropy_T(::GetTickCount());
19 rng.add_entropy_T(::GetMessagePos());
20 rng.add_entropy_T(::GetMessageTime());
21 rng.add_entropy_T(::GetInputState());
22
23 rng.add_entropy_T(::GetCurrentProcessId());
24 rng.add_entropy_T(::GetCurrentThreadId());
25
26 SYSTEM_INFO sys_info{};
27 ::GetSystemInfo(&sys_info); // no return value
28 rng.add_entropy_T(sys_info);
29
30 MEMORYSTATUSEX mem_info{};
31 mem_info.dwLength = sizeof(mem_info);
32 if(::GlobalMemoryStatusEx(&mem_info) != 0) {
33 rng.add_entropy_T(mem_info);
34 }
35
36 POINT point{};
37 if(::GetCursorPos(&point) != 0) {
38 rng.add_entropy_T(point);
39 }
40
41 if(::GetCaretPos(&point) != 0) {
42 rng.add_entropy_T(point);
43 }
44
45 /*
46 Potential other sources to investigate
47
48 GetProductInfo
49 GetComputerNameExA
50 GetSystemFirmwareTable
51 GetVersionExA
52 GetProcessorSystemCycleTime
53 GetProcessHandleCount(GetCurrentProcess())
54 GetThreadTimes(GetCurrentThread())
55 QueryThreadCycleTime
56 QueryIdleProcessorCycleTime
57 QueryUnbiasedInterruptTime
58 */
59
60 // We assume all of the above is basically junk
61 return 0;
62}
63
64} // namespace Botan
void add_entropy_T(const T &t)
Definition rng.h:128
size_t poll(RandomNumberGenerator &rng) override
Definition es_win32.cpp:17