org.bouncycastle.crypto.prng

Class DigestRandomGenerator

Implemented Interfaces:
RandomGenerator

public class DigestRandomGenerator
extends java.lang.Object
implements RandomGenerator

Random generation based on the digest with counter. Calling addSeedMaterial will always increase the entropy of the hash.

Internal access to the digest is synchronized so a single one of these can be shared.

Constructor Summary

DigestRandomGenerator(Digest digest)

Method Summary

void
addSeedMaterial(byte[] inSeed)
Add more seed material to the generator.
void
addSeedMaterial(long rSeed)
Add more seed material to the generator.
void
nextBytes(byte[] bytes)
Fill bytes with random values.
void
nextBytes(byte[] bytes, int start, int len)
Fill part of bytes with random values.

Constructor Details

DigestRandomGenerator

public DigestRandomGenerator(Digest digest)

Method Details

addSeedMaterial

public void addSeedMaterial(byte[] inSeed)
Add more seed material to the generator.
Specified by:
addSeedMaterial in interface RandomGenerator
Parameters:

addSeedMaterial

public void addSeedMaterial(long rSeed)
Add more seed material to the generator.
Specified by:
addSeedMaterial in interface RandomGenerator
Parameters:

nextBytes

public void nextBytes(byte[] bytes)
Fill bytes with random values.
Specified by:
nextBytes in interface RandomGenerator
Parameters:
bytes - byte array to be filled.

nextBytes

public void nextBytes(byte[] bytes,
                      int start,
                      int len)
Fill part of bytes with random values.
Specified by:
nextBytes in interface RandomGenerator
Parameters:
bytes - byte array to be filled.
start - index to start filling at.
len - length of segment to fill.