org.random.rjgodoy.trng
Class MH_SecureRandom

java.lang.Object
  extended by java.util.Random
      extended by java.security.SecureRandom
          extended by org.random.rjgodoy.trng.MH_SecureRandom
All Implemented Interfaces:
Serializable

public class MH_SecureRandom
extends SecureRandom

A SecureRandom implementation accessing www.random.org. Instances of this class do not require RjgodoyProvider to be registered.

Before an instance of this class is constructed (either implicitly by SecureRandom methods, or explicitly by invoking this class constructor), several System properties must be defined for configuring the shared the HTTP connection. Modifying these properties after an instance of this class has been created has no effect.

Other properties (namely INSTANCE_*) are instance-specific and apply to the subsequently created instances.

The org.random.rjgodoy.trng.pool_daemon property is neither a global property nor an instance one: there will be no daemon if all SecureRandomSpi were instantiated with org.random.rjgodoy.trng.pool_daemon equal to false; otherwise, if at least one SecureRandomSpi was instantiated while this property was true and that SecureRandomSpi is reachable, then a daemon will be mantained.

Initialization based on system properties is synchronized with the MH_SecureRandom class object.

TODO: The reachable thing is not implemented. The daemon will be alive forever.

Author:
Javier Godoy
See Also:
Serialized Form

Field Summary
static String CERTFILE
          Local file with the public certificate of www.random.org.
static String INSTANCE_FALLBACK
          The FallbackPolicy that will be used.
static String INSTANCE_MODE
          The GeneratorMode that will be used.
static String INSTANCE_PRNG_ALGORITHM
          The algorithm of the auxiliar PRNG used.
static String INSTANCE_PRNG_PROVIDER
          The provider of the auxiliar PRNG used.
static String MAX_REDIRECTS
          How many HTTP redirects will be followed.
static String POOL_DAEMON
          Enables a thread running in the background for collectiong some bits from the remote source whenever the quota is 1.000.000.
static String SSL_PROTOCOL
          SSL Protocol parameter for instantiating SSLContext.
static String SSL_PROVIDER
          SSL Provider parameter for instantiating SSLContext.
static String TIMEOUT
          How long will the client wait for results from the server (in minutes).
static String USER
          Your mail address.
 
Constructor Summary
MH_SecureRandom()
          Initializes a new instance of SecureRandom using the MH_SecureRandomSpi implementation.
 
Method Summary
 
Methods inherited from class java.security.SecureRandom
generateSeed, getAlgorithm, getInstance, getInstance, getInstance, getProvider, getSeed, next, nextBytes, setSeed, setSeed
 
Methods inherited from class java.util.Random
nextBoolean, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER

public static final String USER
Your mail address.

This property is required (see http://www.random.org/clients/) and should be a valid email address. However, you may provide a fake email address because of privacy issues (for this purpose, @example.org domain addresses are strongly encouraged).

This address will be ONLY used for contacting you if your client instance cause problems. Note that providing a fake email address will not disallow access, but if any problem occurs it will be impossible to contact you, and your IP may be banned in consequence.

Property org.random.rjgodoy.trng.user.
Scopeglobal

See Also:
Constant Field Values

TIMEOUT

public static final String TIMEOUT
How long will the client wait for results from the server (in minutes).

This only applies to submitted request, it has nothing to do about waiting after the quota is exhausted. Use a long timeout value for your requests. Unless you have used up your quota, the RANDOM.ORG server actually tries to satisfy all requests, so if you use a short timeout value, your request will be abandoned halfways and the numbers discarded. This increases load on the server and probably will decrement your quota (because the server had consumed the randomness source, even though it could not deliver the result). Allow at least a couple of minutes for the server to complete your request.

Property org.random.rjgodoy.trng.timeout
Default 2 minutes
Minimum 1 minute
Maximum 596.5232352 minutes (or 0 for "infinite")
Scopeglobal

See Also:
Constant Field Values

CERTFILE

public static final String CERTFILE
Local file with the public certificate of www.random.org. If this property is specified AND ssl is used, then SSL will verify the server certificate against this file.

Property org.random.rjgodoy.trng.certfile
Default null (i.e. do not check).
Scopeglobal

See Also:
Constant Field Values

SSL_PROVIDER

public static final String SSL_PROVIDER
SSL Provider parameter for instantiating SSLContext.

Property org.random.rjgodoy.trng.ssl_provider
Default value null (i.e. any provider)
Scopeglobal

See Also:
Constant Field Values

SSL_PROTOCOL

public static final String SSL_PROTOCOL
SSL Protocol parameter for instantiating SSLContext. If this property is null then SSL will be disabled (a plain HTTP connection will be used). See Appendix A in the Java Secure Socket Extension Reference Guide for information about standard protocol names. Some allowed values are SSL, TLS, TLSv1.1, etc.

Property org.random.rjgodoy.trng.ssl_protocol
Default value null (i.e. SSL disabled)
Scopeglobal

See Also:
Constant Field Values

MAX_REDIRECTS

public static final String MAX_REDIRECTS
How many HTTP redirects will be followed.

Property org.random.rjgodoy.trng.max_redirects
Default value 99
Minimum value 0
Maximum value 2147483647
Scopeglobal

See Also:
Constant Field Values

INSTANCE_FALLBACK

public static final String INSTANCE_FALLBACK
The FallbackPolicy that will be used.

Property org.random.rjgodoy.trng.fallback
Default value TRNG
Allowed values TRNG, PRNG
Scopeinstance

See Also:
Constant Field Values

INSTANCE_MODE

public static final String INSTANCE_MODE
The GeneratorMode that will be used.

Property org.random.rjgodoy.trng.mode
Default value TRNG
Allowed values TRNG, TRNG_XOR_PRNG
Scopeinstance

See Also:
Constant Field Values

INSTANCE_PRNG_PROVIDER

public static final String INSTANCE_PRNG_PROVIDER
The provider of the auxiliar PRNG used.

This property is ignored when fallback is TRNG and the generator mode is GeneratorMode.TRNG.

The RJGODOY provider must not be specified as it would result in an endless loop.

Property org.random.rjgodoy.trng.prng_provider
Default value null (i.e. any provider)
Scopeinstance

See Also:
Constant Field Values

INSTANCE_PRNG_ALGORITHM

public static final String INSTANCE_PRNG_ALGORITHM
The algorithm of the auxiliar PRNG used.

This property is ignored when fallback is TRNG and the generator mode is GeneratorMode.TRNG.

See Appendix A in the Java Secure Socket Extension Reference Guide for information about standard protocol names. As of Java 1.6 the only standard value is SHA1PRNG; other algorithms may be available in some platforms or from third-party libraries.

The algorithm must no be provided by RjgodoyProvider.

Property org.random.rjgodoy.trng.prng_algorithm
Default value null (i.e. default algorithm)
Scopeinstance

See Also:
Constant Field Values

POOL_DAEMON

public static final String POOL_DAEMON
Enables a thread running in the background for collectiong some bits from the remote source whenever the quota is 1.000.000.

The amount of bits which will be collected may be modified through MH_PoolDaemon.setBlockSize(long)

Property org.random.rjgodoy.trng.pool_daemon
Default value false
Allowed values false, true
Scopeshared

See Also:
Constant Field Values
Constructor Detail

MH_SecureRandom

public MH_SecureRandom()
                throws NoSuchAlgorithmException,
                       NoSuchProviderException
Initializes a new instance of SecureRandom using the MH_SecureRandomSpi implementation.

This constructor is only intended for using MH_SecureRandom as a stand-alone class. The preferred mechanism is registering the provider RjgodoyProvider and creating an instance by SecureRandom.getInstance("RJGODOY","MH_TRNG").

Throws:
NoSuchAlgorithmException
NoSuchProviderException


Submit a bug or request a featureCopyright © (2008-2011) Roberto Javier Godoy
Project Web Hosted by SourceForge.netSouceForge.net is registered trademark of SourceForge, Inc., in the United States and other countries.