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

#include <cRandomDSA.h>

Inheritance diagram for GrayLib::cRandomDSA:
GrayLib::cRandomMixerBase Gray::IRandomNoise

Public Member Functions

 cRandomDSA () noexcept
 
 ~cRandomDSA ()
 
void SetZeroHmac () noexcept
 
HRESULT InitRandomHmac (const cHashTypeDef *pHashType, const BYTE *data, size_t data_len)
 
virtual HRESULT GetNoise (void *pOut, size_t out_len) override
 fill array with random bytes. return # bytes filled. More...
 
void UpdateRandomReseed2 (const BYTE *pAddData, size_t add_len)
 
HRESULT UpdateRandomReseed1 (const BYTE *pAddData, size_t add_len)
 
 UNITTEST_FRIEND (cRandomDSA)
 
- Public Member Functions inherited from GrayLib::cRandomMixerBase
 cRandomMixerBase () noexcept
 
virtual ~cRandomMixerBase ()
 
void put_PredictionResistance (bool bPredictionResistance) noexcept
 

Public Attributes

cHashWrap m_HashCtx
 HMAC context (inc. K) cHashSHA1. More...
 
BYTE m_V [cHashWrap::k_HashSizeMax]
 V in the spec. 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...
 

Constructor & Destructor Documentation

◆ cRandomDSA()

GrayLib::cRandomDSA::cRandomDSA ( )
inlinenoexcept

◆ ~cRandomDSA()

GrayLib::cRandomDSA::~cRandomDSA ( )
inline

Member Function Documentation

◆ GetNoise()

HRESULT GrayLib::cRandomDSA::GetNoise ( void *  pData,
size_t  iSize 
)
overridevirtual

fill array with random bytes. return # bytes filled.

HMAC_DRBG random function with optional additional data: 10.1.2.5 (arabic) + 9.3 (Roman)

Note: Automatically reseeds if reseed_counter is reached or PR is enabled.

  • pOut = Buffer to fill
  • out_len = 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

Implements Gray::IRandomNoise.

◆ InitRandomHmac()

HRESULT GrayLib::cRandomDSA::InitRandomHmac ( const cHashTypeDef pHashType,
const BYTE *  data,
size_t  data_len 
)

Simplified HMAC_DRBG initialization (for use with deterministic ECDSA) Initialization of simplified HMAC_DRBG (never reseeds). (For use with deterministic ECDSA.)

  • pHashType = Hash algorithm to use for HMAC_DRBG
  • data = Concatenation of entropy string and additional data
  • data_len = Length of data in bytes
    Returns
    0 if successful, or E_POINTER, or E_OUTOFMEMORY.

◆ SetZeroHmac()

void GrayLib::cRandomDSA::SetZeroHmac ( )
inlinenoexcept

◆ UNITTEST_FRIEND()

GrayLib::cRandomDSA::UNITTEST_FRIEND ( cRandomDSA  )

◆ UpdateRandomReseed1()

HRESULT GrayLib::cRandomDSA::UpdateRandomReseed1 ( const BYTE *  pAddData,
size_t  add_len 
)

HMAC_DRBG reseeding (extracts data from entropy source)

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

< Maximum number of additional input bytes

< Maximum size of (re)seed buffer

◆ UpdateRandomReseed2()

void GrayLib::cRandomDSA::UpdateRandomReseed2 ( const BYTE *  pAddData,
size_t  add_len 
)

HMAC_DRBG update state

  • pAddData = Additional data to update state with, or NULL
  • add_len = Length of additional data, or 0
    Note
    Additional data is optional, pass NULL and 0 as second third argument if no additional data is being used.

Member Data Documentation

◆ m_HashCtx

cHashWrap GrayLib::cRandomDSA::m_HashCtx

HMAC context (inc. K) cHashSHA1.

◆ m_V

BYTE GrayLib::cRandomDSA::m_V[cHashWrap::k_HashSizeMax]

V in the spec.


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