| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttribble.crypto.LFSR
Logical Feedback Shift Register (LFSR) methods.
A Logical Feedback Shift Register, or LFSR, is a binary word of N bits in a Galois configuration that implements a shift operation. The shift operation examines the lowest (least significant) bit of the current value of the register and then exclusive-or's it with the mask value established for the LFSR; it then rotates the bits of the LFSR one bit, resulting in a new state for the LFSR. The output of the shift operation is the low bit.
By shifting an LFSR M times and concatenating the resulting output bits, an M-bit pseudo-random integer can be produced. An LFSR can thus be used as a pseudo-random number generator.
| Field Summary | |
| static short | DFL_SIZEDefault LFSR size (bits). | 
| protected  int[] | m_bitsLFSR state (N bits, as N/32 32-bit words). | 
| protected  int[] | m_maskLFSR exclusive-or mask (N bits, as N/32 32-bit words). | 
| protected  short | m_sizeLFSR width (bits). | 
| static int | SERIESClass version number. | 
| Constructor Summary | |
| LFSR()Default constructor. | |
| LFSR(int size)Constructor. | |
| Method Summary | |
|  byte[] | getBits()Retrieve the contents (value) of this LFSR. | 
|  byte[] | getMask()Retrieve the contents (value) of the mask for this LFSR. | 
| static void | main(java.lang.String[] args)Test driver. | 
|  void | setBits(byte[] val)Set the contents (value) of this LFSR. | 
|  void | setMask(byte[] val)Set the contents (value) of the mask for this LFSR. | 
|  int | shift()Shift (rotate) this LFSR right one bit, returning the resulting output bit. | 
|  long | shift(int n)Shift (rotate) this LFSR multiple times, returning the concatenation of the resulting output bits. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
public static final int SERIES
public static final short DFL_SIZE
protected int[] m_bits
protected int[] m_mask
protected short m_size
| Constructor Detail | 
public LFSR()
public LFSR(int size)
size - The number of bits in the LFSR.  This cannot be less than one or greater
 than 32,767.
java.lang.IllegalArgumentException - Thrown if size is less than one.| Method Detail | 
public static void main(java.lang.String[] args)
                 throws java.lang.Exception
args - Command line arguments.
java.lang.Exceptionpublic byte[] getBits()
public void setBits(byte[] val)
Note that setting all of the bits to zero results in an LFSR that generates a repeating sequence of nothing but zero bits.
val - An array of bytes containing the bit value for this LFSR.  The bits are in
 big-endian order, i.e., element [0] holds the most significant
 bits and element [val.length-1] holds the least significant
 bits.  Most significant bits beyond the size of this LFSR are ignored.public byte[] getMask()
public void setMask(byte[] val)
val - An array of bytes containing the bit value of the exclusive-or mask for
 this LFSR.  The bits are in big-endian order, i.e., element [0]
 holds the most significant bits and element [val.length-1] holds
 the least significant bits.  Most significant bits beyond the size of this
 LFSR are ignored.public int shift()
public long shift(int n)
n - The number of times to shift (rotate) this LFSR, which is also the number
 of bits in the return value.
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||