|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.core.RandomBitsSource
oracle.security.crypto.core.DigestRandomBitsSource
public abstract class DigestRandomBitsSource
A PRNG based on the design pattern in Schneier's Applied Cryptography, using a secure hash algorithm, such as SHA1 or MD5 as a mixing and output primitive.
IMPORTANT: Please note that the generator design relies crucially on the presence of a proper amount and "quality" of seeding entropy (see below). Optional use of the seed(byte[])
method with no arguments causes the generator to be seeded with 20 bytes of seeding material from SpinnerEntropySource
.
It is presumed that users understand the crucial role that seeding entropy plays in the secure initialization of PRNGs. While it is not within the scope of the API documentation to explain how exactly PRNGs work, at the very least one would do well to observe that PRNGs do not "create" randomness so much as they "stretch" and "whiten" an initial pool of randomness. That is, a well-designed PRNG produces a uniform, uncorrelated output sequence, whose words are strongly non-computable from one iteration to the next. However, at their basic design level, they are still deterministic functions -- essentially (one-way) stream ciphers -- whose outputs are, (with some overhead) no more unguessable than their inputs. In this sense the starting value of a generator can be thought of as its "key", and should be strongly protected from eavesdropping or dictionary attacks.
Thus, seed values should never be transmitted in the clear, or stored in (non-secure) files; nor should they ever be re-used, and sources used to "generate" or gather seeding material should themselves be as non-deterministic as possible.
A few caveats about seeding:
EntropySource
, SpinnerEntropySource
Constructor Summary | |
---|---|
protected |
DigestRandomBitsSource() Empty constructor. |
Method Summary | |
---|---|
void |
clear() Clears (zeroes) the pool state of the PRNG, in effect bringing it to the same state as a newly-constructed, unseeded instance. |
protected void |
initialize(AlgorithmIdentifier algID) Initializes this DigestRandomBitsSource . |
byte |
randomByte() Returns the next output byte. |
byte[] |
randomBytes(byte[] bytes) Fills the supplied array with the requsite number of output bytes. |
void |
seed() Seeds this PRNG with 20 bytes of seeding material from the default entropy source. |
void |
seed(byte[] b) Seeds this random bits source with a given array of bytes. |
void |
seed(EntropySource es) Seeds this PRNG with 20 bytes of seeding material from the specified entropy source. |
void |
seed(java.lang.Object o) Seeds the PRNG with the output of the hashCode and toString methods of the current object. |
Methods inherited from class oracle.security.crypto.core.RandomBitsSource |
---|
getDefault, getRNGTest, randomBigInt, randomBigInteger, setDefault |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DigestRandomBitsSource()
Method Detail |
---|
protected void initialize(AlgorithmIdentifier algID)
DigestRandomBitsSource
. Subclasses should call this method in their constructors.algID
- The algorithm identifier of the message digest to be used for this PRNG.AlgID
, MessageDigest
public void seed(byte[] b)
seed
in class RandomBitsSource
public void seed(java.lang.Object o)
hashCode
and toString
methods of the current object. (The entropy available through such conversions is obviously quite variable, and should be estimated conservatively.)public void seed()
seed
in class RandomBitsSource
EntropySource
public void seed(EntropySource es)
seed
in class RandomBitsSource
EntropySource
public byte randomByte()
randomByte
in class RandomBitsSource
public byte[] randomBytes(byte[] bytes)
randomBytes
in class RandomBitsSource
public void clear()
clear
in class RandomBitsSource
|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |