Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.crypto.assembly
Class Cascade  view Cascade download Cascade.java

java.lang.Object
  extended bygnu.javax.crypto.assembly.Cascade

public class Cascade
extends java.lang.Object

A Cascade Cipher is the concatenation of two or more block ciphers each with independent keys. Plaintext is input to the first stage; the output of stage i is input to stage i + 1; and the output of the last stage is the Cascade's ciphertext output.

In the simplest case, all stages in a Cascade have k-bit keys, and the stage inputs and outputs are all n-bit quantities. The stage ciphers may differ (general cascade of ciphers), or all be identical (cascade of identical ciphers).

The term "block ciphers" used above refers to implementations of gnu.crypto.mode.IMode, including the gnu.crypto.mode.ECB mode which basically exposes a symmetric-key block cipher algorithm as a Mode of Operations.

References:

  1. [HAC]: Handbook of Applied Cryptography.
    CRC Press, Inc. ISBN 0-8493-8523-7, 1997
    Menezes, A., van Oorschot, P. and S. Vanstone.


Field Summary
protected  int blockSize
          The curently set block-size for this instance.
static java.lang.String DIRECTION
           
protected  java.util.LinkedList stageKeys
          The ordered list of Stage UIDs to their attribute maps.
protected  java.util.HashMap stages
          The map of Stages chained in this cascade.
protected  Direction wired
          The current operational direction of this instance.
 
Constructor Summary
Cascade()
           
 
Method Summary
 java.lang.Object append(Stage stage)
          Adds to the end of the current chain, a designated Stage.
 java.util.Set blockSizes()
          Returns the java.util.Set of supported block sizes for this Cascade that are common to all of its chained stages.
 int currentBlockSize()
          Returns the currently set block size for the chain.
 void init(java.util.Map attributes)
          Initialises the chain for operation with specific characteristics.
 java.lang.Object insert(int index, Stage stage)
          Inserts a Stage into the current chain, at the specified index (zero-based) position.
private static int lcm(int a, int b)
          Returns the Least Common Multiple of two integers.
 java.lang.Object prepend(Stage stage)
          Adds to the begining of the current chain, a designated Stage.
 void reset()
          Resets the chain for re-initialisation and use with other characteristics.
 boolean selfTest()
          Conducts a simple correctness test that consists of basic symmetric encryption / decryption test(s) for all supported block and key sizes of underlying block cipher(s) wrapped by Mode leafs.
 int size()
          Returns the current number of stages in this chain.
 java.util.Iterator stages()
          Returns an java.util.Iterator over the stages contained in this instance.
 void update(byte[] in, int inOffset, byte[] out, int outOffset)
          Processes exactly one block of plaintext (if initialised in the Direction.FORWARD 55 state) or ciphertext (if initialised in the Direction.REVERSED 55 state).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTION

public static final java.lang.String DIRECTION
See Also:
Constant Field Values

stages

protected java.util.HashMap stages
The map of Stages chained in this cascade.


stageKeys

protected java.util.LinkedList stageKeys
The ordered list of Stage UIDs to their attribute maps.


wired

protected Direction wired
The current operational direction of this instance.


blockSize

protected int blockSize
The curently set block-size for this instance.

Constructor Detail

Cascade

public Cascade()
Method Detail

lcm

private static final int lcm(int a,
                             int b)
Returns the Least Common Multiple of two integers.


append

public java.lang.Object append(Stage stage)
                        throws java.lang.IllegalArgumentException
Adds to the end of the current chain, a designated Stage.


prepend

public java.lang.Object prepend(Stage stage)
                         throws java.lang.IllegalArgumentException
Adds to the begining of the current chain, a designated Stage.


insert

public java.lang.Object insert(int index,
                               Stage stage)
                        throws java.lang.IllegalArgumentException,
                               java.lang.IndexOutOfBoundsException
Inserts a Stage into the current chain, at the specified index (zero-based) position.


size

public int size()
Returns the current number of stages in this chain.


stages

public java.util.Iterator stages()
Returns an java.util.Iterator over the stages contained in this instance. Each element of this iterator is a concrete implementation of a Stage.


blockSizes

public java.util.Set blockSizes()
Returns the java.util.Set of supported block sizes for this Cascade that are common to all of its chained stages. Each element in the returned java.util.Set is an instance of java.lang.Integer.


init

public void init(java.util.Map attributes)
          throws java.security.InvalidKeyException
Initialises the chain for operation with specific characteristics.


currentBlockSize

public int currentBlockSize()
Returns the currently set block size for the chain.


reset

public void reset()
Resets the chain for re-initialisation and use with other characteristics. This method always succeeds.


update

public void update(byte[] in,
                   int inOffset,
                   byte[] out,
                   int outOffset)
Processes exactly one block of plaintext (if initialised in the Direction.FORWARD 55 state) or ciphertext (if initialised in the Direction.REVERSED 55 state).


selfTest

public boolean selfTest()
Conducts a simple correctness test that consists of basic symmetric encryption / decryption test(s) for all supported block and key sizes of underlying block cipher(s) wrapped by Mode leafs. The test also includes one (1) variable key Known Answer Test (KAT) for each block cipher.