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 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.
The name of a property in the attributes map that is passed to the
init
method, representing the cascade's desired wiring direction. The mapped value should be a validgnu.crypto.assembly.Direction
value. If this attribute is omitted,gnu.crypto.assembly.Direction.FORWARD
is used.
Adds to the end of the current chain, a designated stage. Returns a unique identifier for this added stage, within this cascade. An
IllegalArgumentException
is thrown if stage is already in the chain, or it has incompatible characteristics with the current elements already in the chain. On the other hand, anIllegalStateException
will be thrown if the cascade has already been initialized, or if the designated stage is null.
Adds to the beginning of the current chain, a designated stage. Returns a unique identifier for this added stage, within this cascade. An
IllegalArgumentException
is thrown if stage is already in the chain, or it has incompatible characteristics with the current elements already in the chain. On the other hand, anIllegalStateException
will be thrown if the cascade has already been initialized, or if the designated stage is null.
Inserts a designate stage Stage into the current Cascade, at the specified index (zero-based) position. Returns a unique identifier for this added stage, within this cascade. Throws an
IllegalArgumentException
if stage is already in the chain, or it has incompatible characteristics with the current elements already in the chain. Throws anIllegalStateException
if the instance is already initialized. Finally, this method throws anIndexOutOfBoundsException
if index is less than0
or greater than the current size of this cascade.
Returns an
java.util.Iterator
over the stages contained in this instance. Each element of this iterator is a concrete implementation of agnu.crypto.assembly.Stage
.
Returns a
java.util.Set
of supported block sizes for this Cascade that are common to all of its chained stages. Each element in the returned set is an instance ofInteger
.
Initializes the chain for operation with specific characteristics, as specified by the contents of attributes –a set of name-value pairs that describes the desired future behavior of this instance. Throws an
IllegalStateException
if the chain, or any of its stages, is already initialized. Throws anInvalidKeyException
if the initialization data provided with the stage is incorrect or causes an invalid key to be generated.
Returns the currently set block size for the chain. Throws an
IllegalStateException
if the instance is not yet initialized.
Resets the chain for re-initialization and use with other characteristics. This method always succeeds.
Processes exactly one block of plaintext (if initialized in the
gnu.crypto.assembly.Direction#FORWARD
direction) or ciphertext (if initialised in thegnu.crypto.assembly.Direction#REVERSED
direction), from in, starting at index position inOffset, returning the result in out, starting at index position outOffset. Throws anIllegalStateException
if the instance is not yet 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. Returns
true
if the implementation passes the tests. Returnsfalse
otherwise.