Top Description Fields Constructors Methods
org.bouncycastle.crypto.general

public final Class GeneralSecureRandom

extends SecureRandom
Class Inheritance
Imports
java.security.SecureRandom, org.bouncycastle.crypto.EntropySource, org.bouncycastle.crypto.util.EntropyUtil

Base class for DRBG/RNG SecureRandom implementations that use non-FIPS approved algorithms.

Field Summary

Modifier and TypeField and Description
private final DRBG
private final EntropySource
private final boolean
private final SecureRandom

Constructor Summary

AccessConstructor and Description
pack-priv
GeneralSecureRandom(SecureRandom randomSource, DRBG drbg, EntropySource entropySource, boolean predictionResistant)

Method Summary

Modifier and TypeMethod and Description
public byte[]
generateSeed(int
the number of seed bytes to generate.
numBytes
)

Overrides java.security.SecureRandom.generateSeed.

Returns the given number of seed bytes, computed using the seed generation algorithm that this class uses to seed itself.
public int

Returns:

number of bits produced each cycle.
getBlockSize
()

Return the block size of the underlying DRBG

public void
nextBytes(byte[]
the array to be filled in with random bytes.
bytes
)

Overrides java.security.SecureRandom.nextBytes.

Overrides default java.util.random.RandomGenerator.nextBytes.

Generates a user-specified number of random bytes.
public void
nextBytes(byte[] bytes, byte[] additionalInput)

public void
reseed()

Overrides java.security.SecureRandom.reseed.

Force a reseed.
public void
reseed(byte[]
additional input to be used in conjunction with reseed.
additionalInput
)

Force a reseed with additional input.

public void
setSeed(byte[]
the seed.
seed
)

Overrides java.security.SecureRandom.setSeed.

Reseeds this random object with the given seed.
public void
setSeed(long
the seed.
seed
)

Overrides java.security.SecureRandom.setSeed.

Reseeds this random object, using the eight bytes contained in the given long seed.
Inherited from java.security.SecureRandom:
getAlgorithmgetInstancegetInstancegetInstancegetInstancegetInstancegetInstancegetInstanceStronggetParametersgetProvidergetSeednextnextBytesreseedtoString

Field Detail

drbgback to summary
private final DRBG drbg
entropySourceback to summary
private final EntropySource entropySource
predictionResistantback to summary
private final boolean predictionResistant
randomSourceback to summary
private final SecureRandom randomSource

Constructor Detail

GeneralSecureRandomback to summary
pack-priv GeneralSecureRandom(SecureRandom randomSource, DRBG drbg, EntropySource entropySource, boolean predictionResistant)

Method Detail

generateSeedback to summary
public byte[] generateSeed(int numBytes)

Overrides java.security.SecureRandom.generateSeed.

Doc from java.security.SecureRandom.generateSeed.

Returns the given number of seed bytes, computed using the seed generation algorithm that this class uses to seed itself. This call may be used to seed other random number generators.

Parameters
numBytes:int

the number of seed bytes to generate.

Returns:byte[]

the seed bytes.

getBlockSizeback to summary
public int getBlockSize()

Return the block size of the underlying DRBG

Returns:int

number of bits produced each cycle.

nextBytesback to summary
public void nextBytes(byte[] bytes)

Overrides java.security.SecureRandom.nextBytes.

Overrides default java.util.random.RandomGenerator.nextBytes.

Doc from java.security.SecureRandom.nextBytes.

Generates a user-specified number of random bytes.

Parameters
bytes:byte[]

the array to be filled in with random bytes.

nextBytesback to summary
public void nextBytes(byte[] bytes, byte[] additionalInput)
reseedback to summary
public void reseed()

Overrides java.security.SecureRandom.reseed.

Force a reseed.

reseedback to summary
public void reseed(byte[] additionalInput)

Force a reseed with additional input.

Parameters
additionalInput:byte[]

additional input to be used in conjunction with reseed.

setSeedback to summary
public void setSeed(byte[] seed)

Overrides java.security.SecureRandom.setSeed.

Doc from java.security.SecureRandom.setSeed.

Reseeds this random object with the given seed. The seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.

A PRNG SecureRandom will not seed itself automatically if setSeed is called before any nextBytes or reseed calls. The caller should make sure that the seed argument contains enough entropy for the security of this SecureRandom.

Parameters
seed:byte[]

the seed.

setSeedback to summary
public void setSeed(long seed)

Overrides java.security.SecureRandom.setSeed.

Doc from java.security.SecureRandom.setSeed.

Reseeds this random object, using the eight bytes contained in the given long seed. The given seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.

A PRNG SecureRandom will not seed itself automatically if setSeed is called before any nextBytes or reseed calls. The caller should make sure that the seed argument contains enough entropy for the security of this SecureRandom.

This method is defined for compatibility with java.util.Random.

Parameters
seed:long

the seed.