xrpld
Loading...
Searching...
No Matches
xrpl::CsprngEngine Class Reference

A cryptographically secure random number engine. More...

#include <csprng.h>

Collaboration diagram for xrpl::CsprngEngine:

Public Types

using result_type = std::uint64_t

Public Member Functions

 CsprngEngine (CsprngEngine const &)=delete
CsprngEngineoperator= (CsprngEngine const &)=delete
 CsprngEngine (CsprngEngine &&)=delete
CsprngEngineoperator= (CsprngEngine &&)=delete
 CsprngEngine ()
 ~CsprngEngine ()
void mixEntropy (void *buffer=nullptr, std::size_t count=0)
 Mix entropy into the pool.
result_type operator() ()
 Generate a random integer.
void operator() (void *ptr, std::size_t count)
 Fill a buffer with the requested amount of random data.

Static Public Member Functions

static constexpr result_type min ()
static constexpr result_type max ()

Private Attributes

std::mutex mutex_

Detailed Description

A cryptographically secure random number engine.

The engine is thread-safe (it uses a lock to serialize access) and will, automatically, mix in some randomness from std::random_device.

Meets the requirements of UniformRandomNumberEngine

Definition at line 15 of file csprng.h.

Member Typedef Documentation

◆ result_type

Definition at line 21 of file csprng.h.

Constructor & Destructor Documentation

◆ CsprngEngine() [1/3]

xrpl::CsprngEngine::CsprngEngine ( CsprngEngine const & )
delete

◆ CsprngEngine() [2/3]

xrpl::CsprngEngine::CsprngEngine ( CsprngEngine && )
delete

◆ CsprngEngine() [3/3]

xrpl::CsprngEngine::CsprngEngine ( )

Definition at line 16 of file libxrpl/crypto/csprng.cpp.

◆ ~CsprngEngine()

xrpl::CsprngEngine::~CsprngEngine ( )

Definition at line 23 of file libxrpl/crypto/csprng.cpp.

Member Function Documentation

◆ operator=() [1/2]

CsprngEngine & xrpl::CsprngEngine::operator= ( CsprngEngine const & )
delete

◆ operator=() [2/2]

CsprngEngine & xrpl::CsprngEngine::operator= ( CsprngEngine && )
delete

◆ mixEntropy()

void xrpl::CsprngEngine::mixEntropy ( void * buffer = nullptr,
std::size_t count = 0 )

Mix entropy into the pool.

Definition at line 32 of file libxrpl/crypto/csprng.cpp.

◆ operator()() [1/2]

CsprngEngine::result_type xrpl::CsprngEngine::operator() ( )

Generate a random integer.

Definition at line 73 of file libxrpl/crypto/csprng.cpp.

◆ operator()() [2/2]

void xrpl::CsprngEngine::operator() ( void * ptr,
std::size_t count )

Fill a buffer with the requested amount of random data.

Definition at line 57 of file libxrpl/crypto/csprng.cpp.

◆ min()

constexpr result_type xrpl::CsprngEngine::min ( )
staticconstexpr

Definition at line 48 of file csprng.h.

◆ max()

constexpr result_type xrpl::CsprngEngine::max ( )
staticconstexpr

Definition at line 55 of file csprng.h.

Member Data Documentation

◆ mutex_

std::mutex xrpl::CsprngEngine::mutex_
private

Definition at line 18 of file csprng.h.