|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.randomness.Randomness
org.randomness.Truerandomness
public abstract class Truerandomness
This class specifies True Random Number Generator (TRNG) techniques for the reading high quality, unpredictable random bytes from the specified entropy source.
The best way to obtain truly random bits would be to observe a atomic or subatomic physical phenomenon which is believed to exhibit random behavior. Possible sources of entropy include radioactive decay, thermal noise, shot noise, avalanche noise in Zener diodes, clock drift, the timing of actual movements of a hard disk read/write head, and radio noise. Also, some computational things can be used, such a thread synchronization. However, physical phenomena and tools used to measure them generally feature asymmetries and systematic biases that make their outcomes not uniformly random. A randomness extractor, such as a cryptographic hash function, can be used to obtain uniformly distributed bits from a non-uniformly random source, though at a lower bit rate.
TRNG is suitable to use in cryptography. Problems of TRNG is that they usually not fast enough. Some applications need to generate millions of random numbers as quickly as possible. For this purposes Pseudorandom Number Generators or Cryptographically Secure Pseudorandom Number Generators can be used.
The TRNG mechanisms class have four separate functions to handle the TRNG’s internal state:
Entropy source - a source of unpredictable data. There is no assumption that the unpredictable data has a uniform distribution. The entropy source includes a noise source, such as thermal noise or hard drive seek times; a digitization process; an assessment process; an optional conditioning process and health tests.
Conditioned Entropy Source - An entropy source that either includes a
conditioning function or for which conditioning is performed on the output of
the entropy source. The conditioning function ensures that the conditioned
entropy source provides full entropy bitstrings, i.e. the entropy of the
bitstring will be the same as its length. Health tests shall be
performed to determine that the entropy source is continuing to perform
correctly.
Constructor Summary | |
---|---|
protected |
Truerandomness()
Default constructor. |
Method Summary | |
---|---|
abstract void |
close()
The uninstantiate function zeroizes (i.e., erases) the internal state of TRNG (possibly close the entropy source). |
static Truerandomness |
current(TRNG source)
Returns a unique True-random Number Generator isolated to the current thread (thread-local) associated with specified entropy source. |
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one. |
static Truerandomness |
fromCOMM(String port)
TODO PROVISIONAL API, WORK IN PROGRESS: Returns the specified True-random Number Generator using specified COMM connection as a source of entropy. |
static Truerandomness |
fromUSB(String port)
TODO PROVISIONAL API, WORK IN PROGRESS: Returns the specified True-random Number Generator using specified USB connection as a source of entropy. |
int |
hashCode()
Returns the unique hash code value of this Truerandomness (consistent with
equals). |
abstract boolean |
isOpen()
Tells whether or not this TRNG entropy source is open. |
abstract int |
read(ByteBuffer buffer)
The generate function harvest random bits from entropy source per request, can determine entropy of requested bits (optional) and reduce to independent bits if requested bits has low quality entropy. |
double |
readAssessment(ByteBuffer buffer)
TODO PROVISIONAL API, WORK IN PROGRESS: Reads a sequence of bytes from specified entropy source returning the amount of actual entropy obtained from an entropy source. |
boolean |
readConditionally(ByteBuffer buffer,
int min_entropy)
TODO PROVISIONAL API, WORK IN PROGRESS: Reads a sequence of bytes from specified entropy source and the conditioning function ensures that the conditioned entropy source provides entropy bitstrings, with specified min_entropy. |
abstract void |
reset()
The instantiate function determines the initial internal state of TRNG using the instantiate algorithm (possibly opens the entropy source). |
void |
reset(String login,
String password)
TODO PROVISIONAL API, WORK IN PROGRESS: Instantiate with specified login and password (for services with autorization such as random.org and QRBG ). |
static Truerandomness |
shared(TRNG source)
Returns a new shared Truerandom generator that implements the specified entropy gathering mechanism, or True Random Number Generator (TRNG). |
boolean |
test()
TODO PROVISIONAL API, WORK IN PROGRESS: The health test function determines that the TRNG mechanism continues to function correctly; An implementation should provide a capability to test the instantiate function on demand. |
Methods inherited from class org.randomness.Randomness |
---|
asRandom, bind, map, minlen, mixing, newBuffer, nextBoolean, nextByte, nextChar, nextCharASCII, nextDouble, nextFloat, nextHexString, nextInt, nextInt, nextLong, nextLong, nextProbability, nextShort, read, read, read, readFuture, readSink, reversed, shuffle, toString, tryRead |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected Truerandomness()
Method Detail |
---|
public abstract void reset()
Opposite to uninstantiate function.
reset
in class Randomness
public void reset(String login, String password)
random.org
and QRBG
).
login
- password
- public abstract int read(ByteBuffer buffer)
The process to obtain true-random bits from entropy source typically involves the following steps:
read
in interface ReadableByteChannel
read
in class Randomness
buffer
- The buffer into which entropy are to be transferred.
NullPointerException
- if buffer
is null
.
NonReadableChannelException
- If this TRNG was not opened for reading (is
closed).public boolean readConditionally(ByteBuffer buffer, int min_entropy)
Entropy tests shall be performed to determine that the entropy source is continuing to perform correctly.
buffer
- min_entropy
- number bytes of entropy.
true
if returned transfered bytes contains enough
entropy, false
otherwise.public double readAssessment(ByteBuffer buffer)
See Appendix C:(Normative) Entropy and Entropy Sources. C.3 Entropy Assessment
buffer
-
public abstract void close()
Opposite to instantiate function.
After a TRNG is closed, any further attempt to invoke
read operations upon it will
cause a NonReadableChannelException
to be thrown.
If this TRNG is already closed then invoking this method has no effect. This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.
close
in interface Closeable
close
in interface Channel
close
in class Randomness
public abstract boolean isOpen()
isOpen
in interface Channel
isOpen
in class Randomness
public static final Truerandomness shared(TRNG source)
source
- type of entropy source.
public static final Truerandomness current(TRNG source)
ConcurrentModificationException
.
Thread-local TRNG initializes when this method is first called; any further call will return the same instance for the same thread.
source
- type of entropy source.
TRNG.current()
public static final Truerandomness fromUSB(String port)
This method should be used to connect Truerandomness
with
Hardware random number generator connected to base station via USB.
port
- the specified USB connection name.public static final Truerandomness fromCOMM(String port)
This method should be used to connect Truerandomness
with
Hardware random number generator connected to base station via COMM port.
port
- the specified COMM connection name.public boolean test()
Known-answer tests shall be performed on the generate function before the first use of the function in an implementation.
TODO:
false
otherwise.public final boolean equals(Object obj)
equals
in class Object
obj
- the reference object with which to compare.
true
if this object is the same as the obj argument;
false
otherwise.public final int hashCode()
Truerandomness
(consistent with
equals).
hashCode
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |