![JAR search and dependency download from the Maven repository](/logo.png)
nl.open.jwtdependency.org.bouncycastle.crypto.prng.SP800SecureRandom Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-jwt-nodependencies Show documentation
Show all versions of java-jwt-nodependencies Show documentation
This is a drop in replacement for the auth0 java-jwt library (see https://github.com/auth0/java-jwt). This jar makes sure there are no external dependencies (e.g. fasterXml, Apacha Commons) needed. This is useful when deploying to an application server (e.g. tomcat with Alfreso or Pega).
The newest version!
package org.bouncycastle.crypto.prng;
import java.security.SecureRandom;
import org.bouncycastle.crypto.prng.drbg.SP80090DRBG;
public class SP800SecureRandom
extends SecureRandom
{
private final DRBGProvider drbgProvider;
private final boolean predictionResistant;
private final SecureRandom randomSource;
private final EntropySource entropySource;
private SP80090DRBG drbg;
SP800SecureRandom(SecureRandom randomSource, EntropySource entropySource, DRBGProvider drbgProvider, boolean predictionResistant)
{
this.randomSource = randomSource;
this.entropySource = entropySource;
this.drbgProvider = drbgProvider;
this.predictionResistant = predictionResistant;
}
public void setSeed(byte[] seed)
{
synchronized (this)
{
if (randomSource != null)
{
this.randomSource.setSeed(seed);
}
}
}
public void setSeed(long seed)
{
synchronized (this)
{
// this will happen when SecureRandom() is created
if (randomSource != null)
{
this.randomSource.setSeed(seed);
}
}
}
public void nextBytes(byte[] bytes)
{
synchronized (this)
{
if (drbg == null)
{
drbg = drbgProvider.get(entropySource);
}
// check if a reseed is required...
if (drbg.generate(bytes, null, predictionResistant) < 0)
{
drbg.reseed(null);
drbg.generate(bytes, null, predictionResistant);
}
}
}
public byte[] generateSeed(int numBytes)
{
return EntropyUtil.generateSeed(entropySource, numBytes);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy