gnu.crypto.assembly

Class Stage

public abstract class Stage extends Object

A Stage in a Cascade Cipher.

Each stage may be either an implementation of a Block Cipher Mode of Operation (IMode) or another Cascade Cipher (Cascade). Each stage has also a natural operational direction when constructed for inclusion within a Cascade. This natural direction dictates how data flows from one stage into another when stages are chained together in a cascade. One can think of a stage and its natural direction as the specification of how to wire the stage into the chain. The following diagrams may help understand the paradigme. The first shows two stages chained each with a FORWARD direction.

           FORWARD         FORWARD
       +------+       +-------+
       |      |       |       |
       |  +--in --+   |   +--in --+
    ---+  | Stage |   |   | Stage |  +---
          +--out--+   |   +--out--+  |
              |       |       |      |
              +-------+       +------+
 

The second diagram shows two stages, one in a FORWARD direction, while the other is wired in a REVERSED direction.

           FORWARD         REVERSED
       +------+               +------+
       |      |               |      |
       |  +--in --+       +--in --+  |
    ---+  | Stage |       | Stage |  +---
          +--out--+       +--out--+
              |               |
              +---------------+
 

Version: $Revision: 1.7 $

See Also: ModeStage CascadeStage

Field Summary
static StringDIRECTION
protected Directionforward
protected Directionwired
Constructor Summary
protected Stage(Direction forwardDirection)
Method Summary
abstract SetblockSizes()
Returns the Set of supported block sizes for this Stage.
abstract intcurrentBlockSize()
Returns the currently set block size for the stage.
static StagegetInstance(IMode mode, Direction forwardDirection)
static StagegetInstance(Cascade cascade, Direction forwardDirection)
voidinit(Map attributes)
Initialises the stage for operation with specific characteristics.
abstract voidinitDelegate(Map attributes)
voidreset()
Resets the stage for re-initialisation and use with other characteristics.
abstract voidresetDelegate()
abstract booleanselfTest()
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.
voidupdate(byte[] in, int inOffset, byte[] out, int outOffset)
Processes exactly one block of plaintext (if initialised in the FORWARD state) or ciphertext (if initialised in the REVERSED state).
abstract voidupdateDelegate(byte[] in, int inOffset, byte[] out, int outOffset)

Field Detail

DIRECTION

public static final String DIRECTION

forward

protected Direction forward

wired

protected Direction wired

Constructor Detail

Stage

protected Stage(Direction forwardDirection)

Method Detail

blockSizes

public abstract Set blockSizes()
Returns the Set of supported block sizes for this Stage. Each element in the returned Set is an instance of Integer.

Returns: a Set of supported block sizes.

currentBlockSize

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

Returns: the current block size for this stage.

Throws: IllegalStateException if the instance is not initialised.

getInstance

public static final Stage getInstance(IMode mode, Direction forwardDirection)

getInstance

public static final Stage getInstance(Cascade cascade, Direction forwardDirection)

init

public void init(Map attributes)
Initialises the stage for operation with specific characteristics.

Parameters: attributes a set of name-value pairs that describes the desired future behaviour of this instance.

Throws: IllegalStateException if the instance is already initialised. InvalidKeyException if the key data is invalid.

initDelegate

abstract void initDelegate(Map attributes)

reset

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

resetDelegate

abstract void resetDelegate()

selfTest

public abstract 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.

Returns: true if the implementation passes simple correctness tests. Returns false otherwise.

update

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

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.

updateDelegate

abstract void updateDelegate(byte[] in, int inOffset, byte[] out, int outOffset)
Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.