|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Random
org.logi.crypto.random.RandomMD5
This class implements an MD5-based PRNG and must be seeded from another RNG such as PureSpinner.
Random bytes are generated in blocks of 16 bytes. Output-block number i
is r_i = H(s_0...s_i)
. s_0
is the initial seed
which is permuted in each round to form s_i = s_{i-1} + r_i
and H
is the MD5 hash-function where the final step of
appending the length of the message is omitted.
s_0
and each r_i
is taken from the entropy
source. The number of bits in these values should be large enough to
ensure that an appreciable amount of entropy is collected. The default
constructor will create an object which gets entropy from a PureSpinner
object, is seeded with 256 bytes and injects 4 bytes in every round.
This RNG is similar to using MD5 in OFB mode, with a secret IV. In each
round we have r_i = H(s_0...s_i) = H(s_0...s_{i-1}) +
h(H(s_0...s_{i-1}), s_i)
, where h
is the MD5 round
function. We can discard the xor since the left side is known, so the
security of the PRNG hinges on the difficulty of predicting a bit of
h(x,y)
where x
is known and of the form given
above.
The initial seeding may take a while, depending on the entropy source. Therefore the seeding is done in a separate thread which is launched when an object is created. If random bits are requested before the seeding is completed, the request will block.
PureSpinner
,
Serialized FormConstructor Summary | |
RandomMD5()
Create a new instance of the RandomMD5 class. |
|
RandomMD5(java.util.Random seeder,
int seedSize,
int round)
Creates a new instance of the RandomMD5 class. |
Method Summary | |
protected int |
next(int bits)
Generates the next random number. |
void |
nextBytes(byte[] bytes)
Generates a user specified number of random bytes. |
void |
setSeed(byte[] seed,
int off,
int len)
Add the bytes from seed[off..off+len-1] to
the entropy pool. |
void |
setSeed(long seed)
Add the number seed to the entropy pool. |
Methods inherited from class java.util.Random |
nextBoolean, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RandomMD5(java.util.Random seeder, int seedSize, int round)
seedSize
bytes from
seeder
and collects round
bytes from
it for every 16 bytes it outputs.
public RandomMD5()
PureSpinner
Method Detail |
public void setSeed(byte[] seed, int off, int len)
seed[off..off+len-1]
to
the entropy pool.
setSeed
in interface Seedable
public void setSeed(long seed)
seed
to the entropy pool.
setSeed
in interface Seedable
public void nextBytes(byte[] bytes)
protected int next(int bits)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |