This class represents a Stage in a Cascade cipher.
Each stage may be either an implementation of a Block Cipher Mode of
Operation (an instance of gnu.crypto.mode.IMode) or another
Cascade cipher (an instance of 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 paradigm. The first
shows two stages chained together, each wired in the same direction
(Direction#FORWARD).
The second diagram shows two stages, one in a Direction#FORWARD
direction, while the other is wired in a Direction#REVERSED
direction.
A property name in the attributes map that is passed to the
initmethod, representing the stage's desired wiring direction. The mapped value should be a validgnu.crypto.assembly.Directionvalue. If this attribute is omitted,Direction.FORWARDis used.
The following Factory methods, allow instantiation of concrete
Stage class instances that adapt instances of either
gnu.crypto.mode.IMode or (other) Cascade classes to
operate as a Stage in a Cascade:
Given a designated mode (an instance of
gnu.crypto.mode.IMode, and a Direction, this method returns a Stage instance that adapts this designated mode to operate as a Stage in a Cascade.
Given a designated cascade (an instance of
gnu.crypto.assembly.Cascade, and a Direction, this method returns a Stage instance that adapts this designated cascade to operate as a Stage in another Cascade.
The following instance methods are also available:
Returns the
Setof supported block sizes for this Stage. Each element in the returnedSetis an instance ofInteger.
Initializes the stage for operation with specific characteristics. Those characteristics are defined in attributes: a set of name-value pairs that describes the desired future behavior of this instance. This method throws an
IllegalStateExceptionif the instance is already initialized. It throws anjava.security.InvalidKeyExceptionif the key data (used to initialize the underlying Mode or Cascade) is invalid.
Returns the current block size for this stage. Throws an
IllegalStateExceptionif the instance is not yet initialized.
Resets the stage for re-initialization and use with other characteristics. This method always succeeds.
Processes exactly one block of plaintext (if wired in the
Direction#FORWARDdirection) or ciphertext (if wired in theDirection#REVERSEDdirection), from in starting at inOffset, and storing the resulting bytes in out, starting at outOffset. AnIllegalStateExceptionwill be thrown if the stage has not yet been initialized.
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. It returns
trueif the tests succeed, andfalseotherwise.