aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-07-07 10:31:18 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-07-07 10:31:33 +0200
commit642c8e75bccb6645962990fd253ee7ce094d57af (patch)
treefeabc42113eae86c15b5d3ec315ac00415da12bb /src/qt
parentebb37a417a92f58a5b0d91397f3ceb6d00c1b0ff (diff)
parent674c070e5d28bdf1e4e631abc157f6ea0b0b1698 (diff)
downloadbitcoin-642c8e75bccb6645962990fd253ee7ce094d57af.tar.xz
Merge pull request #4399
674c070 [Qt] seed OpenSSL PNRG with Windows event data (Philip Kaufmann)
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/winshutdownmonitor.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/qt/winshutdownmonitor.cpp b/src/qt/winshutdownmonitor.cpp
index f8f9bf45b3..a06f42f66e 100644
--- a/src/qt/winshutdownmonitor.cpp
+++ b/src/qt/winshutdownmonitor.cpp
@@ -6,11 +6,14 @@
#if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
#include "init.h"
+#include "util.h"
#include <windows.h>
#include <QDebug>
+#include <openssl/rand.h>
+
// If we don't want a message to be processed by Qt, return true and set result to
// the value that the window procedure should return. Otherwise return false.
bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult)
@@ -19,6 +22,16 @@ bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pM
MSG *pMsg = static_cast<MSG *>(pMessage);
+ // Seed OpenSSL PRNG with Windows event data (e.g. mouse movements and other user interactions)
+ if (RAND_event(pMsg->message, pMsg->wParam, pMsg->lParam) == 0) {
+ // Warn only once as this is performance-critical
+ static bool warned = false;
+ if (!warned) {
+ LogPrint("%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__);
+ warned = true;
+ }
+ }
+
switch(pMsg->message)
{
case WM_QUERYENDSESSION:
@@ -45,13 +58,13 @@ void WinShutdownMonitor::registerShutdownBlockReason(const QString& strReason, c
typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress(GetModuleHandleA("User32.dll"), "ShutdownBlockReasonCreate");
if (shutdownBRCreate == NULL) {
- qWarning() << "registerShutdownBlockReason : GetProcAddress for ShutdownBlockReasonCreate failed";
+ qWarning() << "registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed";
return;
}
if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
- qWarning() << "registerShutdownBlockReason : Successfully registered: " + strReason;
+ qWarning() << "registerShutdownBlockReason: Successfully registered: " + strReason;
else
- qWarning() << "registerShutdownBlockReason : Failed to register: " + strReason;
+ qWarning() << "registerShutdownBlockReason: Failed to register: " + strReason;
}
#endif