Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cRandomDSA.h
Go to the documentation of this file.
1 //
5 //
6 #ifndef _INC_cRandomDSA_H
7 #define _INC_cRandomDSA_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../Hash/cHashCode.h"
15 
16 namespace GrayLib
17 {
19 
21  {
24  public:
27  size_t m_nEntropyLen;
30 
31  public:
32  cRandomMixerBase() noexcept
33  : m_nReSeedCounter(0)
34  , m_bPredictionResistance(false)
35  , m_nEntropyLen(0)
36  , m_nReSeedInterval(0)
37  , m_pRandom(nullptr)
38  {
39  }
41  {
42  }
43 
44  inline void put_PredictionResistance(bool bPredictionResistance) noexcept
45  {
48  this->m_bPredictionResistance = bPredictionResistance;
49  }
50  };
51 
52  class GRAYLIB_LINK cRandomDSA : public cRandomMixerBase // IRandomNoise
53  {
63  public:
66 
67  public:
68  cRandomDSA() noexcept
69  {
70  SetZeroHmac();
71  }
73  {
74  cMem::ZeroSecure(m_V, sizeof(m_V));
75  }
76 
77  void SetZeroHmac() noexcept
78  {
79  // m_HashCtx.SetZeroHash();
80  cMem::Zero(m_V, sizeof(m_V));
81  }
82 
83  HRESULT InitRandomHmac(const cHashTypeDef* pHashType, const BYTE* data, size_t data_len);
84 
85  virtual HRESULT GetNoise(void* pOut, size_t out_len) override;
86 
92  void UpdateRandomReseed2(const BYTE* pAddData, size_t add_len);
93 
98  //
99  HRESULT UpdateRandomReseed1(const BYTE* pAddData, size_t add_len);
100 
102  };
103 }
104 
105 #endif // _INC_cRandomDSA_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Using X files without the sources and the makefile How to use you just create a debug directory e the sample3 directory must contain Sample3 Final Sample3 exe Sample3 Final Debug Sample3 Final Gfx OpenGL bmp Sample3 Final Gfx tiny_skin bmp Sample3 Final Gfx tiny_4anim x The source files have the DevCpp project file plus the makefile The demos use standard FreeGlut functions Technical without warranty Neither Paul Coppens nor GameDev net make any or either express or with respect to the their or fitness for a specific purpose neither Paul Coppens nor GameDev net shall have any liability to you or any other person or entity with respect to any or damage caused or alleged to have been caused directly or indirectly by the programs provided by Paul Coppens and GameDev net This but is not limited interruption of loss of data
Definition: Readme.txt:39
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cHashTypeDef.h:21
Definition: cHashWrap.h:18
static const size_t k_HashSizeMax
max size bytes.
Definition: cHashWrap.h:23
Definition: cRandomDSA.h:53
UNITTEST_FRIEND(cRandomDSA)
~cRandomDSA()
Definition: cRandomDSA.h:72
void SetZeroHmac() noexcept
Definition: cRandomDSA.h:77
cHashWrap m_HashCtx
HMAC context (inc. K) cHashSHA1.
Definition: cRandomDSA.h:64
cRandomDSA() noexcept
Definition: cRandomDSA.h:68
Definition: cRandomDSA.h:21
bool m_bPredictionResistance
enable prediction resistance (Automatic reseed before every random generation)
Definition: cRandomDSA.h:26
size_t m_nEntropyLen
entropy bytes grabbed on each (re)seed
Definition: cRandomDSA.h:27
int m_nReSeedCounter
reseed counter
Definition: cRandomDSA.h:25
int m_nReSeedInterval
reseed interval
Definition: cRandomDSA.h:28
virtual ~cRandomMixerBase()
Definition: cRandomDSA.h:40
cRandomMixerBase() noexcept
Definition: cRandomDSA.h:32
IRandomNoise * m_pRandom
context for the entropy function
Definition: cRandomDSA.h:29
void put_PredictionResistance(bool bPredictionResistance) noexcept
Definition: cRandomDSA.h:44
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
Definition: cRandom.h:19
static void Zero(void *pData, size_t nSizeBlock) noexcept
Definition: cMem.h:100
static void ZeroSecure(void *pData, size_t nSizeBlock) noexcept
Definition: cMem.h:110