Skip to content

Commit

Permalink
gui: remove OpenSSL PRNG seeding (Windows, Qt only)
Browse files Browse the repository at this point in the history
This removes the code introduced in [dashpay#4399](bitcoin#4399)
that attempts to add additional entroy to the OpenSSL PRNG using Windows messages.
Note that this is specific to bitcoin-qt running on Windows.

```
RAND_event() collects the entropy from Windows events such as mouse movements and other user interaction.
It should be called with the iMsg, wParam and lParam arguments of all messages sent to the window procedure.
It will estimate the entropy contained in the event message (if any), and add it to the PRNG.
The program can then process the messages as usual.
```

Besides BIP70, this is the last place we are directly using OpenSSL in the
GUI code. All other OpenSSL usage is in random.cpp.

Note that we are still also doing Windows specific entropy gathering in multiple
other places. Such as [RandAddSeedPerfmon](https://github.com/bitcoin/bitcoin/blob/master/src/random.cpp#L268)
and [RAND_screen()](https://github.com/bitcoin/bitcoin/blob/master/src/random.cpp#L600).

Also note that if RAND_event returns 0 (PRNG has NOT been seeded with enough data), we're
just logging a message and continuing on, which seems less than ideal.
  • Loading branch information
fanquake authored and Fuzzbawls committed Apr 14, 2021
1 parent 22a7121 commit ada9868
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/qt/winshutdownmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

#if defined(Q_OS_WIN)
#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)
Expand All @@ -23,16 +20,6 @@ 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) {
LogPrintf("%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__);
warned = true;
}
}

switch (pMsg->message) {
case WM_QUERYENDSESSION: {
// Initiate a client shutdown after receiving a WM_QUERYENDSESSION and block
Expand Down

0 comments on commit ada9868

Please sign in to comment.