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;
43 const word32 hi = seed/q;
44 const word32 lo = seed%q;
45 const sword64 test = a*lo - r*hi;
48 seed =
static_cast<word32
>(test);
50 seed =
static_cast<word32
>(test + m);
52 *output++ = byte((GETBYTE(seed, 0) ^ GETBYTE(seed, 1) ^ GETBYTE(seed, 2) ^ GETBYTE(seed, 3)));
58 #ifndef CRYPTOPP_IMPORTS
64 m_randseed(seed, m_size),
66 m_deterministicTimeVector(deterministicTimeVector, deterministicTimeVector ? m_size : 0)
72 memset(m_datetime, 0x00, m_size);
73 memset(m_lastBlock, 0x00, m_size);
76 if (!deterministicTimeVector)
78 time_t tstamp1 = ::time(NULLPTR);
81 clock_t tstamp2 = clock();
99 if (m_deterministicTimeVector.
size())
101 m_cipher->
ProcessBlock(m_deterministicTimeVector, m_datetime);
108 time_t t = ::time(NULLPTR);
114 xorbuf(m_randseed, m_datetime, m_size);
118 if (memcmp(m_lastBlock, m_randseed, m_size) == 0)
119 throw SelfTestFailure(
"X917RNG: Continuous random number generator test failed.");
127 memcpy(m_lastBlock, m_randseed, m_size);
128 xorbuf(m_randseed, m_datetime, m_size);
138 for (
unsigned i=0; i<V; i++)
146 byte inByte = *inString++;
148 sum += ::log(
double(n - tab[inByte]));
155 double MaurerRandomnessTest::GetTestValue()
const
160 double fTu = (sum/(n-Q))/::log(2.0);
162 double value = fTu * 0.1392;
163 return value > 1.0 ? 1.0 : value;