Entrust.getDefaultSecureRandomInstance()
insteadpublic abstract class SecRandom
extends java.security.SecureRandom
Subclasses just need to implement the abstract engineNextBytes()
and engineSetSeed() methods and a no-args constructor.
Subclasses should not seed themselves in the constructor, they should wait
for the application to call a setSeed() method explicitly with
data from an appropriate random source. This class makes sure that
engineNextBytes() is never called before a seed has been set, if
necessary by calling setSeed() itself with data from the default
SeedGenerator.
This class also serves as storage point for the system's default secure PRNG.
Applications which want to use a secure PRNG should typically call
SecRandom.getDefault() instead of instantiating one particular
PRNG directly. This will allow the PRNG used throughout the application to be
set by a simple SecRandom.setDefault() call. The initial default
PRNG is iaik.security.random.SHA1Random.
SecureRandom,
MessageDigestRandom,
SHA1Random,
SeedGenerator,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.Object |
m_sync
Deprecated.
|
protected boolean |
seeded
Deprecated.
Indicates if the SecRandom object has been assigned a seed.
|
| Modifier | Constructor and Description |
|---|---|
protected |
SecRandom()
Deprecated.
Constructor for use by subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
engineNextBytes(byte[] bytes)
Deprecated.
Return the next bytes.length random bytes.
|
protected abstract void |
engineSetSeed(byte[] seed)
Deprecated.
Set the seed to be used for random number generation.
|
static java.security.SecureRandom |
getDefault()
Deprecated.
Return a new instance of the default random number generator.
|
void |
nextBytes(byte[] bytes)
Deprecated.
Return the next bytes.length random bytes.
|
static void |
setDefault(java.lang.Class clazz)
Deprecated.
Set the default random number generator.
|
void |
setSeed()
Deprecated.
Set the seed to the next seed generated by the current default
seed generator.
|
void |
setSeed(byte[] seed)
Deprecated.
Set the seed to be used for random number generation.
|
void |
setSeed(long seed)
Deprecated.
Set the seed to the given long int.
|
generateSeed, getAlgorithm, getInstance, getInstance, getInstance, getProvider, getSeed, nextprotected static java.lang.Object m_sync
protected boolean seeded
protected SecRandom()
public static final java.security.SecureRandom getDefault()
nextBytes()).
Calling getDefault() is the recommended
way of obtaining a PRNG.public static final void setDefault(java.lang.Class clazz)
throws RandomException
getDefault().
The PRNG must have a no-args constructor accessible to this class.java.lang.IllegalArgumentException - if there was an error with the SecureRandomRandomExceptionpublic final void nextBytes(byte[] bytes)
setSeed()
will be called.
This methods calls engineNextBytes().nextBytes in class java.security.SecureRandompublic final void setSeed(byte[] seed)
engineSetSeed().setSeed in class java.security.SecureRandompublic final void setSeed(long seed)
setSeed(byte[]). This method is included mainly
for compatibility, a 64 bit seed will generally be too short
for cryptographic applications and should not be used.setSeed in class java.security.SecureRandompublic final void setSeed()
setSeed(SeedGenerator.getDefault().getSeed());.protected abstract void engineNextBytes(byte[] bytes)
protected abstract void engineSetSeed(byte[] seed)