Skip to content

Commit 6a57ca9

Browse files
committed
Use FRC::randbytes instead of reading >32 bytes from RNG
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.
1 parent d71d0d7 commit 6a57ca9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/qt/test/paymentservertests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ void PaymentServerTests::paymentServerTests()
181181
QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), true);
182182

183183
// Test BIP70 DoS protection:
184-
unsigned char randData[BIP70_MAX_PAYMENTREQUEST_SIZE + 1];
185-
GetRandBytes(randData, sizeof(randData));
184+
auto randdata = FastRandomContext().randbytes(BIP70_MAX_PAYMENTREQUEST_SIZE + 1);
185+
186186
// Write data to a temp file:
187187
QTemporaryFile tempFile;
188188
tempFile.open();
189-
tempFile.write((const char*)randData, sizeof(randData));
189+
tempFile.write((const char*)randdata.data(), randdata.size());
190190
tempFile.close();
191191
// compares 50001 <= BIP70_MAX_PAYMENTREQUEST_SIZE == false
192192
QCOMPARE(PaymentServer::verifySize(tempFile.size()), false);

0 commit comments

Comments
 (0)