Package gnu.crypto.prng

Provides a basic API for using cryptographically strong pseudo random number generation algorithms.

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:

  • "5.6 Definition: A pseudorandom bit generator (PRBG) is said to pass the next-bit test if there is no polynomial-time algorithm which, on input of the first L bits of an output sequence S, can predict the (L+1)st bit of S with a probability significantly grater than 1/2."
  • "5.8 Definition: A PRBG that passes the next-bit test (possibly under some plausible but unproved mathematical assumption such as the intractability of factoring integers) is called a cryptographically secure pseudorandom bit generator (CSPRBG)."

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:

  1. The internal state cannot be determined by knowledge of the input.
  2. It is resistant to bias introduced by specific inputs.
  3. The output does not reveal the state of the generator.
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 seed, and then (b) continuously re-hashing its output.
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.
Provides a basic API for using cryptographically strong pseudo random number generation algorithms.

Package overview

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:

../../..

RC4

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);

Copyright © 2001, 2002, 2003
Free Software Foundation, Inc. All Rights Reserved.