Skip navigation links

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

E10668-03


oracle.security.crypto.fips
Class RNGTest

java.lang.Object
  extended by oracle.security.crypto.fips.RNGTest


public final class RNGTest
extends java.lang.Object

Random number generator continuous self-test class that monitors all RNGs for failure to a constant value, as required by the FIPS 140-2 specification.

If this test fails for any RNG, the crypto module is placed in the ModuleState.ERROR_TEST_RNG_CONTINUOUS error state, and a SelfTestException is thrown. Until this state is cleared (see FIPS_140_2.clearModuleState()), if any attempt to perform a cryptographic operation, including input or output, a ModuleStateException is thrown.

Since:
3.0
See Also:
FIPS_140_2, RandomBitsSource.getRNGTest()

Constructor Summary
RNGTest(RandomBitsSource rng)
          Creates a new RNGTest instance.

 

Method Summary
 void initialize()
          Resets the test and generates and discards an initial random value from the RNG.
 void testRandomByte(byte random)
          Runs the continuous Random Number Generator test for the given random bytes.
 void testRandomBytes(byte[] random, int offset, int length)
          Runs the continuous Random Number Generator test for the given random bytes.

 

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

 

Constructor Detail

RNGTest

public RNGTest(RandomBitsSource rng)
Creates a new RNGTest instance.

The RNGTest should be instantiated in the RandomBitsSource's constructor:

                // Instance variable of the MyRandom class.
                private RNGTest rngTest;

                // MyRandom constructor.
                public MyRandom (boolean seed)
                {
                    //
                    // Set up MyRandom object...
                    //
                    rngTest = new RNGTest(this);
                }
                

The initialize() method must be called before the testRandomBytes of testRandomByte methods can be used.

Parameters:
rng - The RandomBitsSource that this instance of RNGTest will be testing.

Method Detail

initialize

public void initialize()
Resets the test and generates and discards an initial random value from the RNG.

Sub-classes of RandomBitsSource must invoke this method in their seed() methods.


testRandomBytes

public void testRandomBytes(byte[] random,
                            int offset,
                            int length)
Runs the continuous Random Number Generator test for the given random bytes.

Sub-classes of RandomBitsSource must invoke this test in their randomBytes methods before returning any generated random value.

Parameters:
random - The new random value to be compared with the previous value.
offset - The starting index in random from which the bytes to be tested will be taken.
length - The number of bytes from random, starting with offset, that will be tested.
Throws:
SelfTestException - If the test fails or if this RNGTest has not been initialized.
See Also:
initialize(), testRandomByte(byte)

testRandomByte

public void testRandomByte(byte random)
Runs the continuous Random Number Generator test for the given random bytes.

Sub-classes of RandomBitsSource should use this test in their randomByte methods before returning any generated random value.

Parameters:
random - The new random value to be compared with the previous value.
Throws:
SelfTestException - If the test fails or if this RNGTest has not been initialized.
See Also:
initialize(), testRandomBytes(byte[], int, int)

Skip navigation links

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

E10668-03


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