11 NAMESPACE_BEGIN(CryptoPP)
25 #ifndef LCRNG_ORIGINAL_NUMBERS
26 const word32 LC_RNG::m=2147483647L;
27 const word32 LC_RNG::q=44488L;
29 const word16 LC_RNG::a=(
unsigned int)48271L;
30 const word16 LC_RNG::r=3399;
32 const word32 LC_RNG::m=2147483647L;
33 const word32 LC_RNG::q=127773L;
35 const word16 LC_RNG::a=16807;
36 const word16 LC_RNG::r=2836;
46 long test = a*lo - r*hi;
53 *output++ = (GETBYTE(seed, 0) ^ GETBYTE(seed, 1) ^ GETBYTE(seed, 2) ^ GETBYTE(seed, 3));
59 #ifndef CRYPTOPP_IMPORTS
61 X917RNG::X917RNG(
BlockTransformation *c,
const byte *seed,
const byte *deterministicTimeVector)
63 S(cipher->BlockSize()),
67 m_deterministicTimeVector(deterministicTimeVector, deterministicTimeVector ? S : 0)
69 if (!deterministicTimeVector)
71 time_t tstamp1 = time(0);
72 xorbuf(dtbuf, (byte *)&tstamp1, UnsignedMin(
sizeof(tstamp1), S));
73 cipher->ProcessBlock(dtbuf);
74 clock_t tstamp2 = clock();
75 xorbuf(dtbuf, (byte *)&tstamp2, UnsignedMin(
sizeof(tstamp2), S));
76 cipher->ProcessBlock(dtbuf);
88 if (m_deterministicTimeVector.size())
91 IncrementCounterByOne(m_deterministicTimeVector, S);
96 xorbuf(dtbuf, (byte *)&c, UnsignedMin(
sizeof(c), S));
97 time_t t = time(NULL);
98 xorbuf(dtbuf+S-UnsignedMin(
sizeof(t), S), (byte *)&t, UnsignedMin(
sizeof(t), S));
103 xorbuf(randseed, dtbuf, S);
107 if (memcmp(m_lastBlock, randseed, S) == 0)
108 throw SelfTestFailure(
"X917RNG: Continuous random number generator test failed.");
111 size_t len = UnsignedMin(S, size);
112 target.ChannelPut(channel, randseed, len);
116 memcpy(m_lastBlock, randseed, S);
117 xorbuf(randseed, dtbuf, S);
124 MaurerRandomnessTest::MaurerRandomnessTest()
127 for (
unsigned i=0; i<V; i++)
135 byte inByte = *inString++;
137 sum += log(
double(n - tab[inByte]));
144 double MaurerRandomnessTest::GetTestValue()
const
146 if (BytesNeeded() > 0)
149 double fTu = (sum/(n-Q))/log(2.0);
151 double value = fTu * 0.1392;
152 return value > 1.0 ? 1.0 : value;