AXL Software

com.theorem.radserver3.radutil
Class RadRand

Object
  extended byRadRand

public final class RadRand
extends Object

SecureRandom implementation using the underlying SecureRandom class as a key generator. A frequentely re-keyed MersenneTwister PRNG is used to generate bytes which are run through a message digest.


Field Summary
static String Secure
          String indicating this is the real PRNG.
 
Constructor Summary
RadRand()
           
 
Method Summary
static void add(byte[] d)
          Add data to the pool.
static void add(int d)
          Add data to the pool.
static void add(long d)
          Add data to the pool.
static String getVersion()
          Get the version.
static byte nextByte()
          Get the next byte - used in packet id's and other one byte integer values.
static byte[] nextBytes(byte[] buf)
          Get the next bytes.
static byte[] nextBytes(byte[] buf, int offset, int count)
          Get the next bytes.
static int nextInt()
          Get the next integer.
static int nextInt(int max)
          Get the next integer.
static int nextUnsignedByte()
          Get the next unsigned byte - used in packet id's and other one byte integer values.
static void start()
          Initialize the PRNG.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Secure

public static String Secure
String indicating this is the real PRNG. There is a fake distribution for demonstration purposes that isn't random at all.

Constructor Detail

RadRand

public RadRand()
Method Detail

add

public static void add(byte[] d)
Add data to the pool.


add

public static void add(int d)
Add data to the pool.


add

public static void add(long d)
Add data to the pool.


getVersion

public static String getVersion()
Get the version.

Returns:
Version.

nextByte

public static byte nextByte()
Get the next byte - used in packet id's and other one byte integer values. This is from a pool of bytes created by the nextBytes() method. In the server the typical use for integers is for CHAP Identifiers, packet identifiers

Returns:
Next byte.

nextBytes

public static byte[] nextBytes(byte[] buf)
Get the next bytes.

Parameters:
buf - Buffer to fill.
Returns:
the filled buffer.

nextBytes

public static byte[] nextBytes(byte[] buf,
                               int offset,
                               int count)
Get the next bytes.

Parameters:
buf - Buffer to fill.
offset - offset into buffer.
count - Number of bytes to fill.
Returns:
the filled buffer.

nextInt

public static int nextInt()
Get the next integer.

Returns:
Next integer.

nextInt

public static int nextInt(int max)
Get the next integer.

Parameters:
max - The maximum value to return.
Returns:
a random value between 0 (inclusive) and the specified value (exclusive).

nextUnsignedByte

public static int nextUnsignedByte()
Get the next unsigned byte - used in packet id's and other one byte integer values. This is from a pool of bytes created by the nextBytes() method. In the server the typical use for integers is for CHAP Identifiers, packet identifiers

Returns:
Next integer.

start

public static void start()
                  throws RADIUSException
Initialize the PRNG.

Throws:
RADIUSException

AXL Software

Submit a bug report or feature request

Copyright 1998-2010 AXL Software PO Box 97, Viola, Delaware 19979, U.S.A. All Rights Reserved.