Provides a basic API for using cryptographically strong pseudo random number generation algorithms.
See: Description
Interface Summary | |
---|---|
EntropySource | A generic interface for adding random bytes to an entropy pool. |
IPBE |
Trivial interface to group Password-based encryption property names. |
IRandom |
The basic visible methods of any pseudo-random number generator. The [HAC] defines a PRNG (as implemented in this library) as follows:
IMPLEMENTATION NOTE: Although all the concrete classes in this package implement the Cloneable interface, it is important to note here that such an operation, for those algorithms that use an underlting symmetric key block cipher, DOES NOT clone any session key material that may have been used in initialising the source PRNG (the instance to be cloned). |
RandomEventListener | An interface for entropy accumulators that will be notified of random events. |
Class Summary | |
---|---|
ARCFour | RC4 is a stream cipher developed by Ron Rivest. |
BasePRNG |
An abstract class to facilitate implementing PRNG algorithms. |
CSPRNG |
An entropy pool-based pseudo-random number generator based on the PRNG in Peter Gutmann's cryptlib (http://www.cs.auckland.ac.nz/~pgut001/cryptlib/). The basic properties of this generator are:
|
Fortuna | The Fortuna continuously-seeded pseudo-random number generator. |
Fortuna.Generator | The Fortuna generator function. |
ICMGenerator |
Counter Mode is a way to define a pseudorandom keystream generator using a block cipher. |
LimitReachedException | A checked exception that indicates that a pseudo random number generated has reached its theoretical limit in generating random bytes. |
MDGenerator |
A simple pseudo-random number generator that relies on a hash algorithm,
that (a) starts its operation by hashing a |
PBKDF2 |
An implementation of the key derivation function KDF2 from PKCS #5: Password-Based Cryptography (PBE). |
PRNGFactory |
A Factory to instantiate pseudo random number generators. |
RandomEvent | An interface for entropy accumulators that will be notified of random events. |
UMacGenerator |
KDFs (Key Derivation Functions) are used to stretch user-supplied key material to specific size(s) required by high level cryptographic primitives. |
Random number generators, used in cryptography, are based on algorithms which output sequences of statically independent and unbiased bits.
The following diagram shows the important classes participating in this package:
The following example shows how to instantiate, use, and clone a PRNG based on the RC4 stream cipher algorithm.
byte[] b1 = new byte[16]; byte[] b2 = new byte[16]; HashMap attrib = new HashMap(); attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, new byte[0]); IRandom r1 = PRNGFactory.getInstance(Registry.ARCFOUR_PRNG); r1.init(attrib); r1.nextBytes(b1, 0, b1.length); IRandom r2 = (IRandom) r1.clone(); r1.nextBytes(b1, 0, b1.length); r2.nextBytes(b2, 0, b1.length);