Cryptography Reference
In-Depth Information
point for the generation of prime numbers, we would like to be able to create
large numbers with a specified number of binary digits; for these, the highest bit
should be set to 1, and the remaining bits should be randomly generated.
12.1 A Simple Random Number Generator
First we construct a linear congruence generator from whose sequential
values we will take the digits of a CLINT random number. The parameters
a = 6364136223846793005 and m =2 64 for our generator are taken from
the table with results of the spectral test in Knuth ([Knut], pages 102-104). The
sequence X i +1 =( X i · a +1)mod m thus generated possesses a maximal
period length λ = m as well as good statistical properties, as we conclude from
the test results presented in the table. The generator is implemented in the
following function rand64_l() . On each call to rand64_l() the next number in the
sequence is generated and then stored in the global CLINT object SEED64 , declared
as static . The parameter a is stored in the global variable A64 . The function
returns a pointer to SEED64 .
linear congruence generator with period length 2 64
Function:
clint * rand64_l (void);
Syntax:
Return:
pointer to SEED64 with calculated random number
clint *
rand64_l (void)
{
mul_l (SEED64, A64, SEED64);
inc_l (SEED64);
The reduction modulo 2 64 proceeds simply by setting the length field of SEED64
and costs almost no computational time.
SETDIGITS_L (SEED64, MIN (DIGITS_L (SEED64), 4));
return ((clint *)SEED64);
}
Next, we require a function for setting the initial values for rand64_l() . This
function is called seed64_l() , and it accepts a CLINT object as input, from which
it takes at most four of the most-significant digits as initial values in SEED64 .
The previous value of SEED64 is copied into the static CLINT object BUFF64 , and a
pointer to BUFF64 is returned.
 
Search WWH ::




Custom Search