Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-05


oracle.security.crypto.core
Class RandomBitsSource

java.lang.Object
  extended by oracle.security.crypto.core.RandomBitsSource

Direct Known Subclasses:
DigestRandomBitsSource, DSARandomBitsSource, SRRandomBitsSource

public abstract class RandomBitsSource
extends java.lang.Object

An abstract class representing secure PRNG (pseudo-random number generator) implementations.

Please note that, by the very nature of PRNGs, the security of their output depends crucially on the amount and "quality" of seeding entropy used. Implementing classes should provide guidance as to their proper initialization and use.

Each instance of this class contains an instance of RNGTest, which must be used by sub-classes in FIPS Approved Mode to ensure proper continuous testing of their output for failure to a constant value.

See Also:
FIPS_140_2, getRNGTest(), EntropySource, SpinnerEntropySource

Constructor Summary
protected RandomBitsSource()
          Empty constructor.

 

Method Summary
abstract  void clear()
          Clears out sensitive data pools within the PRNG.
static RandomBitsSource getDefault()
          Get the default random bits source.
protected  RNGTest getRNGTest()
          Returns the RNGTest instance for this RandomBitsSource instance.
 oracle.security.crypto.core.math.BigInt randomBigInt(int len)
          Provided as an alternative to BigInt(int, java.util.Random).
 java.math.BigInteger randomBigInteger(int len)
          Provided as an alternative to BigInteger(int, java.util.Random).
abstract  byte randomByte()
          Generate a random byte.
 byte[] randomBytes(byte[] bytes)
          Fill a byte array with random bytes.
 void seed()
          Seed from the system default entropy source.
abstract  void seed(byte[] seed)
          Seed the PRNG with the supplied array of bytes.
abstract  void seed(EntropySource egs)
          Seed the PRNG with a default number of bytes from the supplied entropy source.
static void setDefault(RandomBitsSource rbs)
          Sets the default random bits source for the current run-time environment.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

RandomBitsSource

protected RandomBitsSource()
Empty constructor.

Method Detail

getRNGTest

protected final RNGTest getRNGTest()
Returns the RNGTest instance for this RandomBitsSource instance.
Since:
3.0

seed

public abstract void seed(byte[] seed)
Seed the PRNG with the supplied array of bytes.

seed

public abstract void seed(EntropySource egs)
Seed the PRNG with a default number of bytes from the supplied entropy source.

Note that entropy source algorithms are frequently time and/or resource-intensive, which may cause significant delay before this method returns.


seed

public void seed()
Seed from the system default entropy source.

randomByte

public abstract byte randomByte()
Generate a random byte.

randomBytes

public byte[] randomBytes(byte[] bytes)
Fill a byte array with random bytes.

randomBigInteger

public java.math.BigInteger randomBigInteger(int len)
Provided as an alternative to BigInteger(int, java.util.Random). Returns a BigInteger uniformly distributed within the interval of the requested length (polling for as many random bytes from the random bits source as necessary). (Note that, as a consequence, the bit length of the returned integer will -- exactly half the time -- be less than the length requested.)

randomBigInt

public oracle.security.crypto.core.math.BigInt randomBigInt(int len)
Provided as an alternative to BigInt(int, java.util.Random). Returns a BigInt uniformly distributed within the interval of the requested length (polling for as many random bytes from the random bits source as necessary). (Note that, as a consequence, the bit length of the returned integer will -- exactly half the time -- be less than the length requested.)

getDefault

public static RandomBitsSource getDefault()
Get the default random bits source. If the default is not set, a new sub-class of RandomBitsSource is created, seeded and returned. Note: Successive calls to getDefault will return additional references to the same RandomBitsSource instance. This must be taken into consideration by programmers developing multi-threaded applications.
See Also:
setDefault(oracle.security.crypto.core.RandomBitsSource)

setDefault

public static void setDefault(RandomBitsSource rbs)
Sets the default random bits source for the current run-time environment.
See Also:
getDefault()

clear

public abstract void clear()
Clears out sensitive data pools within the PRNG. Note that in so doing, the PRNG may be brought to an unusable state (e.g. requiring new seed material). Implementing classes should throw an exception when random bytes are request in this case.

Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-05


Copyright © 2005, 2013, Oracle. All rights reserved.