umontreal.iro.lecuyer.rng
Class RandRijndael
- java.lang.Object
-
- umontreal.iro.lecuyer.rng.RandomStreamBase
-
- umontreal.iro.lecuyer.rng.RandRijndael
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, CloneableRandomStream, RandomStream
public class RandRijndael extends RandomStreamBase
Implements a RNG using the Rijndael block cipher algorithm (AES) with key and block lengths of 128 bits. A block of 128 bits is encrypted by the Rijndael algorithm to generate 128 pseudo-random bits. Those bits are split into four words of 32 bits which are returned successively by the method nextValue. The unencrypted block is the state of the generator. It is incremented by 1 at every four calls to nextValue. Thus, the period is 2130 and jumping ahead is easy. The values of V, W and Z are 240, 242 and 282, respectively (seeRandomStreamfor their definition). Seeds/states must be given as 16-dimensional vectors of bytes (8-bit integers). The default initial seed is a vector filled with zeros.The Rijndael implementation used here is that of the Cryptix Development Team, which can be found on the Rijndael creators' page .
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RandRijndael()Constructs a new stream.RandRijndael(java.lang.String name)Constructs a new stream with the identifier name (used in the toString method).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description RandRijndaelclone()Clones the current generator and return its copy.byte[]getState()Returns the current state of the stream, represented as an array of four integers.voidresetNextSubstream()Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.voidresetStartStream()Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.voidresetStartSubstream()Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.static voidsetPackageSeed(byte[] seed)Sets the initial seed for the class RandRijndael to the 16 bytes of the vector seed[0..15].voidsetSeed(byte[] seed)This method is discouraged for normal use.java.lang.StringtoString()Returns a string containing the current state of this stream.-
Methods inherited from class umontreal.iro.lecuyer.rng.RandomStreamBase
formatState, formatStateFull, increasedPrecision, nextArrayOfDouble, nextArrayOfInt, nextDouble, nextInt
-
-
-
-
Constructor Detail
-
RandRijndael
public RandRijndael()
Constructs a new stream.
-
RandRijndael
public RandRijndael(java.lang.String name)
Constructs a new stream with the identifier name (used in the toString method).- Parameters:
name- name of the stream
-
-
Method Detail
-
setPackageSeed
public static void setPackageSeed(byte[] seed)
Sets the initial seed for the class RandRijndael to the 16 bytes of the vector seed[0..15]. This will be the initial state (or seed) of the next created stream. The default seed for the first stream is (0, 0,…, 0, 0).- Parameters:
seed- array of 16 elements representing the seed
-
setSeed
public void setSeed(byte[] seed)
This method is discouraged for normal use. Initializes the stream at the beginning of a stream with the initial seed seed[0..15]. This method only affects the specified stream; the others are not modified, so the beginning of the streams will not be spaced Z values apart. For this reason, this method should only be used in very exceptional cases; proper use of the reset... methods and of the stream constructor is preferable.- Parameters:
seed- array of 16 elements representing the seed
-
getState
public byte[] getState()
Returns the current state of the stream, represented as an array of four integers. It should be noted that each state of this generator returns 4 successive values. The particular value of these 4 which will be returned next is not given by this method.- Returns:
- the current state of the stream
-
clone
public RandRijndael clone()
Clones the current generator and return its copy.- Specified by:
clonein interfaceCloneableRandomStream- Overrides:
clonein classRandomStreamBase- Returns:
- A deep copy of the current generator
-
resetStartStream
public void resetStartStream()
Description copied from interface:RandomStreamReinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.- Specified by:
resetStartStreamin interfaceRandomStream- Specified by:
resetStartStreamin classRandomStreamBase
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its current substream: Cg is set to Bg.- Specified by:
resetStartSubstreamin interfaceRandomStream- Specified by:
resetStartSubstreamin classRandomStreamBase
-
resetNextSubstream
public void resetNextSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.- Specified by:
resetNextSubstreamin interfaceRandomStream- Specified by:
resetNextSubstreamin classRandomStreamBase
-
toString
public java.lang.String toString()
Description copied from interface:RandomStreamReturns a string containing the current state of this stream.- Specified by:
toStringin interfaceRandomStream- Specified by:
toStringin classRandomStreamBase- Returns:
- the state of the generator formated as a string
-
-
DMelt 3.0 © DataMelt by jWork.ORG