00001 #ifndef CRYPTOPP_RNG_H
00002 #define CRYPTOPP_RNG_H
00003
00004 #include "cryptlib.h"
00005 #include "filters.h"
00006
00007 NAMESPACE_BEGIN(CryptoPP)
00008
00010 class NullRNG : public RandomNumberGenerator
00011 {
00012 byte GenerateByte() {assert(false); return 0x7d;}
00013 };
00014
00016
00017 class LC_RNG : public RandomNumberGenerator
00018 {
00019 public:
00020 LC_RNG(word32 init_seed)
00021 : seedBytes((byte *)&seed) {seed=init_seed;}
00022
00023 byte GenerateByte();
00024
00025 word32 GetSeed() {return seed;}
00026
00027 private:
00028 word32 seed;
00029 byte *const seedBytes;
00030
00031 static const word32 m;
00032 static const word32 q;
00033 static const word16 a;
00034 static const word16 r;
00035 };
00036
00038
00039 class X917RNG : public RandomNumberGenerator
00040 {
00041 public:
00042
00043 X917RNG(BlockTransformation *cipher, const byte *seed);
00044
00045 byte GenerateByte();
00046
00047 private:
00048 member_ptr<BlockTransformation> cipher;
00049 const int S;
00050 SecByteBlock dtbuf;
00051 SecByteBlock randseed, randbuf;
00052 int randbuf_counter;
00053 };
00054
00059 class MaurerRandomnessTest : public Sink
00060 {
00061 public:
00062 MaurerRandomnessTest();
00063
00064 void Put(byte inByte);
00065 void Put(const byte *inString, unsigned int length);
00066
00067
00068
00069 unsigned int BytesNeeded() const {return n >= (Q+K) ? 0 : Q+K-n;}
00070
00071
00072
00073 double GetTestValue() const;
00074
00075 private:
00076 enum {L=8, V=256, Q=2000, K=2000};
00077 double sum;
00078 unsigned int n;
00079 unsigned int tab[V];
00080 };
00081
00082 NAMESPACE_END
00083
00084 #endif