Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

rng.h

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         // cipher will be deleted by destructor
00043         X917RNG(BlockTransformation *cipher, const byte *seed);
00044 
00045         byte GenerateByte();
00046 
00047 private:
00048         member_ptr<BlockTransformation> cipher;
00049         const int S;                    // blocksize of cipher
00050         SecByteBlock dtbuf;     // buffer for enciphered timestamp
00051         SecByteBlock randseed, randbuf;
00052         int randbuf_counter;    // # of unused bytes left in randbuf
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         // BytesNeeded() returns how many more bytes of input is needed by the test
00068         // GetTestValue() should not be called before BytesNeeded()==0
00069         unsigned int BytesNeeded() const {return n >= (Q+K) ? 0 : Q+K-n;}
00070 
00071         // returns a number between 0.0 and 1.0, describing the quality of the
00072         // random numbers entered
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

Generated at Mon Jan 15 01:16:36 2001 for Crypto++ by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000