gnu.crypto.assembly
public class Cascade extends 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 IMode, including the ECB mode which basically exposes a symmetric-key block cipher algorithm as a Mode of Operations.
References:
Version: $Revision: 1.8 $
Field Summary | |
---|---|
protected int | blockSize The curently set block-size for this instance. |
static String | DIRECTION |
protected LinkedList | stageKeys The ordered list of Stage UIDs to their attribute maps. |
protected 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 | |
---|---|
Object | append(Stage stage)
Adds to the end of the current chain, a designated Stage.
|
Set | blockSizes()
Returns the 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(Map attributes)
Initialises the chain for operation with specific characteristics.
|
Object | insert(int index, Stage stage)
Inserts a Stage into the current chain, at the specified index
(zero-based) position.
|
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.
|
Iterator | stages()
Returns an Iterator over the stages contained in this instance.
|
void | update(byte[] in, int inOffset, byte[] out, int outOffset) |
Parameters: stage the Stage to append to the chain.
Returns: a unique identifier for this stage, within this cascade.
Throws: IllegalStateException if the instance is already initialised. IllegalArgumentException if the designated stage is already in the chain, or it has incompatible characteristics with the current elements already in the chain.
Cascade
that are common to all of its chained stages. Each
element in the returned Set is an instance of Integer.
Returns: a Set of supported block sizes common to all the stages of the chain.
Returns: the current block size for the chain.
Throws: IllegalStateException if the instance is not initialised.
Parameters: attributes a set of name-value pairs that describes the desired future behaviour of this instance.
Throws: IllegalStateException if the chain, or any of its stages, is already initialised. InvalidKeyException if the intialisation data provided with the stage is incorrect or causes an invalid key to be generated.
Parameters: stage the Stage to insert into the chain.
Returns: a unique identifier for this stage, within this cascade.
Throws: IllegalArgumentException if the designated stage is already in
the chain, or it has incompatible characteristics with the current
elements already in the chain. IllegalStateException if the instance is already initialised. IndexOutOfBoundsException if index
is less than
0
or greater than the current size of this cascade.
Parameters: stage the Stage to prepend to the chain.
Returns: a unique identifier for this stage, within this cascade.
Throws: IllegalStateException if the instance is already initialised. IllegalArgumentException if the designated stage is already in the chain, or it has incompatible characteristics with the current elements already in the chain.
Returns: true
if the implementation passes simple
correctness tests. Returns false
otherwise.
Returns: the current count of stages in this chain.
Returns: an Iterator over the stages contained in this instance. Each element of the returned iterator is a concrete instance of a Stage.
Parameters: in the plaintext. inOffset index of in
from which to start considering
data. out the ciphertext. outOffset index of out
from which to store result.
Throws: IllegalStateException if the instance is not initialised.