This chapter describes two patterns implemneted by the GNU Crypto library that allow users to combine the basic cipher (and other) primitives into higher level components in order to offer more flexible functionalities. These two patterns are: Cascade and Assembly.
The Cascade is a means of assembling block cipher Modes of Operations into an ordered sequence of stages. A stage is a representation of a Mode (of Operations) wired in a designated direction: FORWARD or REVERSED. A Mode staged in the FORWARD direction would encrypt input blocks, producing ciphertext, while the same Mode, wired in the REVERSED direction would do the opposite; i.e. decrypt an input text producing a plaintext.
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).
An Assembly is a construction of an ordered set of Transformer objects. Each Transformer is wired to operate in PRE_PROCESSING or POST_PROCESSING mode -the Transformer's Operation. In PRE_PROCESSING, the input is first processed by the Transformer before being passed to the rest of the chain, while in POST_PROCESSING state, the Transformer first passes the input to the rest of the chain and only processes the output of the returned data.