Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GraySSL::cRandomTest Class Reference

#include <cRandomTest.h>

Inheritance diagram for GraySSL::cRandomTest:
GrayLib::cRandomMixerBase Gray::IRandomNoise

Public Member Functions

 cRandomTest () noexcept
 
 ~cRandomTest () noexcept
 
virtual HRESULT GetNoise (void *pData, size_t nSize) override
 
HRESULT InitRandomTest (IRandomNoise *pRand, const BYTE *pUserData, size_t len)
 
HRESULT ctr_drbg_reseed (const BYTE *pAddData, size_t len)
 
void ctr_drbg_update (const BYTE *pAddData, size_t add_len)
 CTR_DRBG update state. More...
 
 UNITTEST_FRIEND (cRandomTest)
 
- Public Member Functions inherited from GrayLib::cRandomMixerBase
 cRandomMixerBase () noexcept
 
virtual ~cRandomMixerBase ()
 
void put_PredictionResistance (bool bPredictionResistance) noexcept
 

Public Attributes

cCipherAES m_aes_ctx
 AES context. More...
 
BYTE counter [16]
 counter (V) More...
 
- Public Attributes inherited from GrayLib::cRandomMixerBase
int m_nReSeedCounter
 reseed counter More...
 
bool m_bPredictionResistance
 enable prediction resistance (Automatic reseed before every random generation) More...
 
size_t m_nEntropyLen
 entropy bytes grabbed on each (re)seed More...
 
int m_nReSeedInterval
 reseed interval More...
 
IRandomNoisem_pRandom
 context for the entropy function More...
 

Static Public Attributes

static const int k_CTR_DRBG_MAX_SEED_INPUT = 384
 Maximum size of (re)seed buffer. More...
 
static const int k_CTR_DRBG_BLOCKSIZE = 16
 Block size used by the cipher. More...
 
static const int k_CTR_DRBG_KEYSIZE = 32
 Key size used by the cipher. More...
 
static const int k_CTR_DRBG_SEEDLEN = (k_CTR_DRBG_KEYSIZE + k_CTR_DRBG_BLOCKSIZE)
 The seed length (counter + AES key) More...
 

Detailed Description

pseudo random data for tests. DRBG = Deterministic Random Bit Generator. used only for testing.

Constructor & Destructor Documentation

◆ cRandomTest()

GraySSL::cRandomTest::cRandomTest ( )
inlinenoexcept

◆ ~cRandomTest()

GraySSL::cRandomTest::~cRandomTest ( )
inlinenoexcept

Member Function Documentation

◆ ctr_drbg_reseed()

HRESULT GraySSL::cRandomTest::ctr_drbg_reseed ( const BYTE *  pAddData,
size_t  len 
)

CTR_DRBG reseeding (extracts data from entropy source)

  • pAddData = Additional data to add to state (Can be NULL)
  • len = Length of additional data
    Returns
    0 if successful, or FVE_E_FIPS_RNG_CHECK_FAILED

◆ ctr_drbg_update()

void GraySSL::cRandomTest::ctr_drbg_update ( const BYTE *  pAddData,
size_t  add_len 
)

CTR_DRBG update state.

  • pAddData = Additional data to update start with
  • add_len = Length of additional data
    Note
    If add_len is greater than k_CTR_DRBG_MAX_SEED_INPUT, only the first k_CTR_DRBG_MAX_SEED_INPUT bytes are used, the remaining ones are silently discarded.

◆ GetNoise()

HRESULT GraySSL::cRandomTest::GetNoise ( void *  pData,
size_t  nSize 
)
overridevirtual

generate random with additional update input

Note
Automatically reseeds if reseed_counter is reached.
  • pData = Buffer to fill
  • nSize Length of the buffer
Returns
0 if successful, or FVE_E_FIPS_RNG_CHECK_FAILED, or DISP_E_OVERFLOW

< Maximum number of requested bytes per call

< Maximum number of additional input bytes

Implements Gray::IRandomNoise.

◆ InitRandomTest()

HRESULT GraySSL::cRandomTest::InitRandomTest ( IRandomNoise pRand,
const BYTE *  pUserData,
size_t  len 
)

CTR_DRBG initialization

Note
Personalization data can be provided in addition to the more generic entropy source to make this instantiation as unique as possible.
  • pRand = Entropy context
  • pUserData = Personalization data (Device specific identifiers) (Can be nullptr)
  • len = Length of personalization data
Returns
0 if successful, or FVE_E_FIPS_RNG_CHECK_FAILED

< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256)

◆ UNITTEST_FRIEND()

GraySSL::cRandomTest::UNITTEST_FRIEND ( cRandomTest  )

Member Data Documentation

◆ counter

BYTE GraySSL::cRandomTest::counter[16]

counter (V)

◆ k_CTR_DRBG_BLOCKSIZE

const int GraySSL::cRandomTest::k_CTR_DRBG_BLOCKSIZE = 16
static

Block size used by the cipher.

◆ k_CTR_DRBG_KEYSIZE

const int GraySSL::cRandomTest::k_CTR_DRBG_KEYSIZE = 32
static

Key size used by the cipher.

◆ k_CTR_DRBG_MAX_SEED_INPUT

const int GraySSL::cRandomTest::k_CTR_DRBG_MAX_SEED_INPUT = 384
static

Maximum size of (re)seed buffer.

◆ k_CTR_DRBG_SEEDLEN

const int GraySSL::cRandomTest::k_CTR_DRBG_SEEDLEN = (k_CTR_DRBG_KEYSIZE + k_CTR_DRBG_BLOCKSIZE)
static

The seed length (counter + AES key)

◆ m_aes_ctx

cCipherAES GraySSL::cRandomTest::m_aes_ctx

AES context.


The documentation for this class was generated from the following files: