![JAR search and dependency download from the Maven repository](/logo.png)
org.bouncycastle.crypto.general.X931PseudoRandom Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bc-fips-debug Show documentation
Show all versions of bc-fips-debug Show documentation
The FIPS 140-2 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-2 level 1. This jar contains the debug version JCE provider and low-level API for the BC-FJA version 1.0.2.3, FIPS Certificate #3514. Please note the debug jar is not certified.
package org.bouncycastle.crypto.general;
class X931PseudoRandom
implements DRBG
{
private final X931RNG drbg;
X931PseudoRandom(X931RNG drbg)
{
this.drbg = drbg;
}
/**
* Return the block size of the underlying DRBG
*
* @return number of bits produced each cycle.
*/
public int getBlockSize()
{
return drbg.getBlockSize();
}
public int generate(byte[] output, byte[] additionalInput, boolean predictionResistant)
{
if (additionalInput != null)
{
throw new IllegalArgumentException("X9.31 PRNG does not use additionalInput");
}
synchronized (this)
{
// check if a reseed is required...
if (drbg.generate(output, predictionResistant) < 0)
{
drbg.reseed();
return drbg.generate(output, predictionResistant);
}
return output.length;
}
}
public void reseed(byte[] additionalInput)
{
if (additionalInput != null)
{
throw new IllegalArgumentException("X9.31 PRNG does not use additionalInput");
}
synchronized (this)
{
drbg.reseed();
}
}
/**
* Force a reseed.
*/
public void reseed()
{
synchronized (this)
{
drbg.reseed();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy