@Immutable public final class VerySecureRandom extends Object
/dev/random may require waiting for the result as it uses
so-called entropy pool, where random data may not be available at the moment.
/dev/urandom returns as many bytes as user requested and thus it
is less random than /dev/random.
Use -Djava.security.egd=file:/dev/./urandom on the commandline
to use urandom
Find a good description that states how it is done this way:
https://www.cigital.com/blog/proper-use-of-javas-securerandom/ Updated to
https://www.synopsys.com/blogs/software-security/proper-use-of-javas-securerandom/
Initialize SecureRandom This is a lengthy operation, to be done only upon
initialization of the application.
On Linux SecureRandom.getInstanceStrong () takes more or less forever (when
using /dev/random) - up to 30 minutes until enough entropy is present
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_RE_SEED_INTERVAL |
| Modifier and Type | Method and Description |
|---|---|
static SecureRandom |
getInstance() |
static int |
getReSeedInterval()
Get the interval of
getInstance() calls after which the random
should be re-seeded. |
static void |
setReSeedInterval(int nReseedInterval)
Set the interval of
getInstance() calls after which the random
should be re-seeded. |
public static final int DEFAULT_RE_SEED_INTERVAL
public static void setReSeedInterval(@Nonnegative int nReseedInterval)
getInstance() calls after which the random
should be re-seeded.nReseedInterval - The re-seed interval. Must be ≥ 0. The value of 0 means: don't
re-seed. The default value is 20.@Nonnegative public static int getReSeedInterval()
getInstance() calls after which the random
should be re-seeded.@Nonnull public static SecureRandom getInstance()
SecureRandom instance that does the hard work. Never
null.Copyright © 2014–2019 Philip Helger. All rights reserved.