Package gnu.crypto.prng

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

Interface Summary

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

Class Summary

ARCFour RC4 is a stream cipher developed by Ron Rivest.
BasePRNG An abstract class to facilitate implementing PRNG algorithms.
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.
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:

../../../../diagrams/prng_class_diag.png" width=476 height=265 border=0>

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);
<!-- $Revision: 1.4 $ -->

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