edu.rit.crypto
Class MuH1Random

java.lang.Object
  extended by edu.rit.crypto.MuH1Random

public class MuH1Random
extends Object

Class MuH1Random provides a pseudorandom number generator (PRNG) based on the MicroHash-One (μH-1) 32-bit one-way hash function. To use the μH1 PRNG, construct a new instance of class MuH1Random or re-initialize an existing instance by calling the initialize() method; seed the PRNG by calling the accumulateSeed() method one or more times; and repeatedly call next() to generate a series of pseudorandom numbers.

The μH-1 PRNG does not have the goal of generating a highly random sequence of values. While the μH-1 PRNG does okay on statistical randomness tests, other PRNGs do a lot better. Rather, the μH-1 PRNG's goals are (a) to run quickly, and yet (b) to make it difficult for an attacker to predict the next value in the sequence, having observed the previous values in the sequence.

As with the μH-1 compression function, the μH-1 PRNG is intended to be used in applications where it only has to withstand attack for a short time, a few milliseconds at most. See class MuH1 for further information.

Note: Class MuH1Random is multiple thread safe.


Constructor Summary
MuH1Random()
          Construct a new μH-1 PRNG.
MuH1Random(int seed)
          Construct a new μH-1 PRNG.
MuH1Random(long seed)
          Construct a new μH-1 PRNG.
 
Method Summary
 void accumulateSeed(int seed)
          Accumulate the given int seed value into this μH-1 PRNG.
 void accumulateSeed(long seed)
          Accumulate the given long seed value into this μH-1 PRNG.
 void initialize()
          Set this μH-1 PRNG to the initial state.
 int next()
          Generate this μH-1 PRNG's next pseudorandom number.
 int next(int n)
          Generate this μH-1 PRNG's next pseudorandom number in the range 0 through n-1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MuH1Random

public MuH1Random()
Construct a new μH-1 PRNG. The PRNG is initialized but not seeded. The PRNG should be seeded before generating any pseudorandom numbers.


MuH1Random

public MuH1Random(int seed)
Construct a new μH-1 PRNG. The PRNG is initialized and seeded with the given int value. To defend against attack, the seed should be a random value not known to the attacker.

Parameters:
seed - Seed.

MuH1Random

public MuH1Random(long seed)
Construct a new μH-1 PRNG. The PRNG is initialized and seeded with the given long value. To defend against attack, the seed should be a random value not known to the attacker.

Parameters:
seed - Seed.
Method Detail

initialize

public void initialize()
Set this μH-1 PRNG to the initial state. The PRNG should then be seeded before generating any pseudorandom numbers.


accumulateSeed

public void accumulateSeed(int seed)
Accumulate the given int seed value into this μH-1 PRNG. To defend against attack, the seed should be a random value not known to the attacker.

Parameters:
seed - Seed.

accumulateSeed

public void accumulateSeed(long seed)
Accumulate the given long seed value into this μH-1 PRNG. To defend against attack, the seed should be a random value not known to the attacker.

Parameters:
seed - Seed.

next

public int next()
Generate this μH-1 PRNG's next pseudorandom number.

Returns:
Pseudorandom number in the range -231 .. 231 - 1.

next

public int next(int n)
Generate this μH-1 PRNG's next pseudorandom number in the range 0 through n-1.

Parameters:
n - Upper bound. Must be greater than zero.
Returns:
Pseudorandom number in the range 0 .. n-1.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.