Cryptography Reference
In-Depth Information
x 2 x 1 2
47497112 2
69993144 (mod 136064437)
z 2 69993144 8 1000 base 2 (mod 2 4 ) (the 4 least significant bits of x 2 )
The final “random” bitstream produced is
10001000.
Admittedly, it isn't much to look at. We need to generate a much larger stream, and will
do so in the next example.
E XAMPLE . Here we produce a much longer stream of 100 blocks, each of bit length 4. We
will use exactly the same parameters
p
= 11351,
q
= 11987,
n
=
pq
= 136064437,
j
= 4, and
the seed
s
= 80331757.
1000 1000 0101 1111 1110 0101 1101 0001 0000 0000 0000 1000 1100 1101
0001 0101 0110 1010 1110 0110 0110 0000 1011 0011 1000 1010 1100 1010
0000 1101 1110 0100 0111 1111 1010 0000 1011 1001 1110 1001 1100 0100
0011 1000 0101 1000 0010 1001 0100 0101 1111 0001 0110 1100 0101 0000
0110 1011 1001 0001 0000 0101 0011 1100 0111 0011 0101 0111 0000 1000
0010 1111 1111 1100 0110 0001 0011 1110 0111 0001 1111 0010 1111 1100
1011 0011 1111 1111 1110 1010 1000 1001 0111 0111 0010 0100 1001 0010
1100
You may wish to check these values, or write a program to check them. (I recommend
the latter.)
The CSPRBG Class I have designed a class which implements the Blum-Blum-Shub
algorithm for generating random bitstreams. For convenience, the modulus n = pq will be
fixed at 1025-1026 bits. Using this bit length for n , we should choose no more than 10 of
the least significant bits after each squaring. For convenience again, we will choose the 8
least significant bits, allowing us to easily place them in a byte array using the method fill-
Bytes(). We can also retrieve a single byte using the getRandomByte() method. The code
for the CSPRBG class follows.
import java.math.*;
import java.security.*;
public class CSPRBG {
BigInteger p,q,n,seed;
public CSPRBG(byte[] seed) {
this.seed=new BigInteger(seed);
if (this.seed.bitLength()<515) throw new
IllegalArgumentException(“Seed too small”);
SecureRandom sr=new SecureRandom(seed);
//Use a secureRandom object to get the strong primes
PrimeGenerator pg=new PrimeGenerator(513,16,sr);
do {p=pg.getStrongPrime();}
 
Search WWH ::




Custom Search