CryptoSys API  6.22.1
Public Types | Static Public Member Functions | List of all members
crsysapi::Rng Class Reference

Random Number Generator to NIST SP800-90. More...

Public Types

enum  Opts : unsigned int
 Rng options More...
 

Static Public Member Functions

static bvec_t Bytes (int n)
 Generate an array of random bytes. More...
 
static std::string Hex (int n)
 Generate an array of n random bytes encoded in hex.
 
static int Initialize (const std::string &seedFile)
 Initialize the RNG generator using a seed file. More...
 
static int InitializeEx (Opts opts=Opts::Default)
 Query and initialize the RNG generator using Intel(R) DRNG, if available. More...
 
static int32_t Number (int32_t lower, int32_t upper)
 Generate a random integer in a given range. More...
 
static int Octet ()
 Generate a single random octet (byte) More...
 
static int UpdateSeedFile (const std::string &seedFile)
 Update the RNG seed file with more entropy. More...
 

Detailed Description

Random Number Generator to NIST SP800-90.

Member Enumeration Documentation

◆ Opts

enum crsysapi::Rng::Opts : unsigned int

Rng options

Enumerator
Default 

Default options.

NoIntelDrng 

Turn off support for INTEL(R) DRNG for the current session.

Member Function Documentation

◆ Bytes()

static bvec_t crsysapi::Rng::Bytes ( int  n)
static

Generate an array of random bytes.

Parameters
nRequired number of random bytes
Returns
Array of random bytes

◆ Initialize()

static int crsysapi::Rng::Initialize ( const std::string &  seedFile)
static

Initialize the RNG generator using a seed file.

Parameters
seedFileFull path name of seed file.
Returns
Zero on success.
Remarks
If the seed file does not exist, it will be created. If it exists, it will be automatically updated with more entropy (the same as using Rng::UpdateSeedFile)

◆ InitializeEx()

static int crsysapi::Rng::InitializeEx ( Opts  opts = Opts::Default)
static

Query and initialize the RNG generator using Intel(R) DRNG, if available.

Parameters
optsOption flags (optional)
Returns
Support status for Intel(R) DRNG. If available, then a positive value (1,2,3); else a negative error code.

◆ Number()

static int32_t crsysapi::Rng::Number ( int32_t  lower,
int32_t  upper 
)
static

Generate a random integer in a given range.

Parameters
lowerlower value of range
upperupper value of range
Returns
Random integer x: lower <= x <= upper

◆ Octet()

static int crsysapi::Rng::Octet ( )
static

Generate a single random octet (byte)

Returns
Integer value randomly chosen between 0 and 255.

◆ UpdateSeedFile()

static int crsysapi::Rng::UpdateSeedFile ( const std::string &  seedFile)
static

Update the RNG seed file with more entropy.

Parameters
seedFileFull path name of seed file.
Returns
Zero on success.
Copyright © 2001-24 D.I. Management Services Pty Limited ABN 78 083 210 584 Australia. All rights reserved. <www.di-mgt.com.au> <www.cryptosys.net>. Generated on Sat Jan 6 2024 18:00:07 by Doxygen 1.9.1.