rng.h

来自「各种加密算法的集合」· C头文件 代码 · 共 49 行

H
49
字号
  #ifndef RNG_H 
#define RNG_H 

#include "cryptlib.h" 

// linear congruential generator 
// originally by William S. England 

// do not use for cryptographic purposes 

class LC_RNG : public RandomNumberGenerator 
{ 
public: 
LC_RNG(word32 init_seed) 
: seedptr((byte *)&amt;seed) {seed=init_seed;} 

byte GetByte(); 

private: 
word32 seed; 
byte *const seedptr; 

static const word32 m; 
static const word32 q; 
static const word16 a; 
static const word16 r; 
}; 

// RNG derived from ANSI X9.17 Appendix C 

class X917RNG : public RandomNumberGenerator 
{ 
public: 
// cipher will be deleted by destructor 
X917RNG(BlockTransformation *cipher, const byte *seed); 
~X917RNG(); 

byte GetByte(); 

private: 
BlockTransformation *const cipher; 
const int S; // blocksize of cipher 
byte *const dtbuf; // buffer for enciphered timestamp 
byte *const randseed; 
byte *const randbuf; 
int randbuf_counter; // # of unused bytes left in randbuf 
}; 

#endif 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?