Module org.cryptomator.cryptolib
Package org.cryptomator.cryptolib.common
Class ReseedingSecureRandom
java.lang.Object
java.util.Random
java.security.SecureRandom
org.cryptomator.cryptolib.common.ReseedingSecureRandom
- All Implemented Interfaces:
Serializable
Wraps a fast CSPRNG, which gets reseeded automatically after a certain amount of bytes has been generated.
Java 8 Example:
SecureRandom csprng = ReseedingSecureRandom.create(SecureRandom.getInstanceStrong());
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionReseedingSecureRandom(SecureRandom seeder, SecureRandom csprng, long reseedAfter, int seedLength) -
Method Summary
Modifier and TypeMethodDescriptionstatic ReseedingSecureRandomcreate(SecureRandom seeder) Creates a pre-configured automatically reseeding SHA1PRNG instance, reseeding itself with 440 bits from the given seeder after generating 2^30 bytes, thus satisfying recommendations by NIST SP 800-90A Rev 1.Methods inherited from class java.security.SecureRandom
generateSeed, getAlgorithm, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstanceStrong, getParameters, getProvider, getSeed, next, nextBytes, nextBytes, reseed, reseed, setSeed, setSeed, toString
-
Constructor Details
-
ReseedingSecureRandom
public ReseedingSecureRandom(SecureRandom seeder, SecureRandom csprng, long reseedAfter, int seedLength) - Parameters:
seeder- RNG for high-quality random numbers. E.g.SecureRandom.getInstanceStrong()in Java 8+ environments.csprng- A fast csprng implementation, such asSHA1PRNG, that will be wrapped by this instance.reseedAfter- How many bytes can be read from thecsprng, before a new seed will be generated.seedLength- Number of bytes generated byseederin order to seedcsprng.
-
-
Method Details
-
create
Creates a pre-configured automatically reseeding SHA1PRNG instance, reseeding itself with 440 bits from the given seeder after generating 2^30 bytes, thus satisfying recommendations by NIST SP 800-90A Rev 1.- Parameters:
seeder- RNG for high-quality random numbers. E.g.SecureRandom.getInstanceStrong()in Java 8+ environments.- Returns:
- An automatically reseeding SHA1PRNG suitable as CSPRNG for most applications.
-