Save This Page
Home » openjdk-7 » sun.security » provider » [javadoc | source]
sun.security.provider
abstract class: SeedGenerator [javadoc | source]
java.lang.Object
   sun.security.provider.SeedGenerator

Direct Known Subclasses:
    ThreadedSeedGenerator, NativeSeedGenerator, URLSeedGenerator

This class generates seeds for the cryptographically strong random number generator.

The seed is produced using one of two techniques, via a computation of current system activity or from an entropy gathering device.

In the default technique the seed is produced by counting the number of times the VM manages to loop in a given period. This number roughly reflects the machine load at that point in time. The samples are translated using a permutation (s-box) and then XORed together. This process is non linear and should prevent the samples from "averaging out". The s-box was designed to have even statistical distribution; it's specific values are not crucial for the security of the seed. We also create a number of sleeper threads which add entropy to the system by keeping the scheduler busy. Twenty such samples should give us roughly 160 bits of randomness.

These values are gathered in the background by a daemon thread thus allowing the system to continue performing it's different activites, which in turn add entropy to the random seed.

The class also gathers miscellaneous system information, some machine dependent, some not. This information is then hashed together with the 20 seed bytes.

The alternative to the above approach is to acquire seed material from an entropy gathering device, such as /dev/random. This can be accomplished by setting the value of the "securerandom.source" security property (in the Java security properties file) to a URL specifying the location of the entropy gathering device. In the event the specified URL cannot be accessed the default mechanism is used. The Java security properties file is located in the file named <JAVA_HOME>/lib/security/java.security. <JAVA_HOME> refers to the value of the java.home system property, and specifies the directory where the JRE is installed.

Nested Class Summary:
static class  SeedGenerator.URLSeedGenerator   
Field Summary
static final  String URL_DEV_RANDOM     
static final  String URL_DEV_URANDOM     
Method from sun.security.provider.SeedGenerator Summary:
generateSeed,   getSeedByte,   getSeedBytes,   getSystemEntropy
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.security.provider.SeedGenerator Detail:
 public static  void generateSeed(byte[] result) 
    Fill result with bytes from the queue. Wait for it if it isn't ready.
 abstract byte getSeedByte()
  void getSeedBytes(byte[] result) 
 static byte[] getSystemEntropy() 
    Retrieve some system information, hashed.