mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Generic PRNG framework:
* A new, unified interface for generating random numbers and filling buffers supporting any engine that fits the UniformRandomNumberGenerator concept; * Automatically seeded replacement for rand using the fast xorshift+ PRNG engine; * A CSPRNG engine that can be used with the new framework when needing to to generate cryptographically secure randomness. * Unit test cleanups to work with new engine.
This commit is contained in:
@@ -23,8 +23,9 @@
|
||||
#include <ripple/protocol/impl/secp256k1.h>
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/crypto/GenerateDeterministicKey.h>
|
||||
#include <ripple/crypto/RandomNumbers.h>
|
||||
#include <ripple/crypto/csprng.h>
|
||||
#include <beast/crypto/secure_erase.h>
|
||||
#include <beast/random/rngfill.h>
|
||||
#include <ed25519-donna/ed25519.h>
|
||||
#include <cstring>
|
||||
|
||||
@@ -150,7 +151,10 @@ Seed
|
||||
randomSeed()
|
||||
{
|
||||
std::uint8_t buf[16];
|
||||
random_fill(buf, sizeof(buf));
|
||||
beast::rngfill(
|
||||
buf,
|
||||
sizeof(buf),
|
||||
crypto_prng());
|
||||
Seed seed(Slice{ buf, sizeof(buf) });
|
||||
beast::secure_erase(buf, sizeof(buf));
|
||||
return seed;
|
||||
@@ -170,7 +174,10 @@ SecretKey
|
||||
randomSecretKey()
|
||||
{
|
||||
std::uint8_t buf[32];
|
||||
random_fill(buf, sizeof(buf));
|
||||
beast::rngfill(
|
||||
buf,
|
||||
sizeof(buf),
|
||||
crypto_prng());
|
||||
SecretKey sk(Slice{ buf, sizeof(buf) });
|
||||
beast::secure_erase(buf, sizeof(buf));
|
||||
return sk;
|
||||
|
||||
Reference in New Issue
Block a user