Skip to content

Commit

Permalink
Use FRC::randbytes instead of reading >32 bytes from RNG
Browse files Browse the repository at this point in the history
There was only one place in the codebase where we're directly reading >32 bytes from
the RNG. One possibility would be to make the built-in RNG support large reads, but
using FastRandomContext lets us reuse code better.

There is no change in behavior here, because the FastRandomContext constructor
uses GetRandBytes internally.
  • Loading branch information
sipa committed Jan 13, 2019
1 parent d71d0d7 commit 6a57ca9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/qt/test/paymentservertests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ void PaymentServerTests::paymentServerTests()
QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), true);

// Test BIP70 DoS protection:
unsigned char randData[BIP70_MAX_PAYMENTREQUEST_SIZE + 1];
GetRandBytes(randData, sizeof(randData));
auto randdata = FastRandomContext().randbytes(BIP70_MAX_PAYMENTREQUEST_SIZE + 1);

// Write data to a temp file:
QTemporaryFile tempFile;
tempFile.open();
tempFile.write((const char*)randData, sizeof(randData));
tempFile.write((const char*)randdata.data(), randdata.size());
tempFile.close();
// compares 50001 <= BIP70_MAX_PAYMENTREQUEST_SIZE == false
QCOMPARE(PaymentServer::verifySize(tempFile.size()), false);
Expand Down

0 comments on commit 6a57ca9

Please sign in to comment.