rippled
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ripple::csprng_engine Class Reference

A cryptographically secure random number engine. More...

Collaboration diagram for ripple::csprng_engine:
Collaboration graph
[legend]

Public Types

using result_type = std::uint64_t
 

Public Member Functions

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

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 37 of file csprng.h.

Member Typedef Documentation

◆ result_type

Definition at line 43 of file csprng.h.

Constructor & Destructor Documentation

◆ csprng_engine() [1/3]

ripple::csprng_engine::csprng_engine ( csprng_engine const &  )
delete

◆ csprng_engine() [2/3]

ripple::csprng_engine::csprng_engine ( csprng_engine &&  )
delete

◆ csprng_engine() [3/3]

ripple::csprng_engine::csprng_engine ( )

Definition at line 30 of file csprng.cpp.

◆ ~csprng_engine()

ripple::csprng_engine::~csprng_engine ( )

Definition at line 37 of file csprng.cpp.

Member Function Documentation

◆ operator=() [1/2]

csprng_engine& ripple::csprng_engine::operator= ( csprng_engine const &  )
delete

◆ operator=() [2/2]

csprng_engine& ripple::csprng_engine::operator= ( csprng_engine &&  )
delete

◆ mix_entropy()

void ripple::csprng_engine::mix_entropy ( void *  buffer = nullptr,
std::size_t  count = 0 
)

Mix entropy into the pool.

Definition at line 46 of file csprng.cpp.

◆ operator()() [1/2]

csprng_engine::result_type ripple::csprng_engine::operator() ( )

Generate a random integer.

Definition at line 91 of file csprng.cpp.

◆ operator()() [2/2]

void ripple::csprng_engine::operator() ( void *  ptr,
std::size_t  count 
)

Fill a buffer with the requested amount of random data.

Definition at line 74 of file csprng.cpp.

◆ min()

static constexpr result_type ripple::csprng_engine::min ( )
staticconstexpr

Definition at line 70 of file csprng.h.

◆ max()

static constexpr result_type ripple::csprng_engine::max ( )
staticconstexpr

Definition at line 77 of file csprng.h.

Member Data Documentation

◆ mutex_

std::mutex ripple::csprng_engine::mutex_
private

Definition at line 40 of file csprng.h.