00001
00002
00003 #ifndef CRYPTOPP_RNG_H
00004 #define CRYPTOPP_RNG_H
00005
00006 #include "cryptlib.h"
00007 #include "filters.h"
00008
00009 NAMESPACE_BEGIN(CryptoPP)
00010
00011
00012
00013 class LC_RNG : public RandomNumberGenerator
00014 {
00015 public:
00016 LC_RNG(word32 init_seed)
00017 : seed(init_seed) {}
00018
00019 void GenerateBlock(byte *output, size_t size);
00020
00021 word32 GetSeed() {return seed;}
00022
00023 private:
00024 word32 seed;
00025
00026 static const word32 m;
00027 static const word32 q;
00028 static const word16 a;
00029 static const word16 r;
00030 };
00031
00032
00033
00034 class CRYPTOPP_DLL X917RNG : public RandomNumberGenerator, public NotCopyable
00035 {
00036 public:
00037
00038 X917RNG(BlockTransformation *cipher, const byte *seed, const byte *deterministicTimeVector = 0);
00039
00040 void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size);
00041
00042 private:
00043 member_ptr<BlockTransformation> cipher;
00044 unsigned int S;
00045 SecByteBlock dtbuf;
00046 SecByteBlock randseed, m_lastBlock, m_deterministicTimeVector;
00047 };
00048
00049
00050
00051
00052
00053 class MaurerRandomnessTest : public Bufferless<Sink>
00054 {
00055 public:
00056 MaurerRandomnessTest();
00057
00058 size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
00059
00060
00061
00062 unsigned int BytesNeeded() const {return n >= (Q+K) ? 0 : Q+K-n;}
00063
00064
00065
00066 double GetTestValue() const;
00067
00068 private:
00069 enum {L=8, V=256, Q=2000, K=2000};
00070 double sum;
00071 unsigned int n;
00072 unsigned int tab[V];
00073 };
00074
00075 NAMESPACE_END
00076
00077 #endif