The IMode interface is similar to the IBlockCipher
interface, except modes have a state associated with them, e.g.
whether the instance is used for encryption or decryption. The
IMode interface is usually the one that is used when encrypting
or decrypting; IBlockCipher is used when the lowest level--the
cipher function itself--needs to be accessed. IMode extends
IBlockCipher interface, and thus all methods specified in that
interface are implemented in modes, and have the same meaning. The
properties passed to the init method of IBlockCipher may
also be passed to the init mehtod of IMode, along with the
following property names.
diagrams/mode_class_diag.png
init
method. Values for this property are an java.lang.Integer
containing either the ENCRYPTION constant or the
DECRYPTION constant.
STATE property, wrapped in a
java.lang.Integer, which indicates that the instance is to be
used for encryption.
STATE property, wrapped in a
java.lang.Integer, which indicates that the instance is to be
used for decryption.
java.lang.Integer of the block size. If
omitted, the underlying cipher's block size is used.
MODE_BLOCK_SIZE property. If omitted a byte array consisting of
zeros is used.
state
property given to the init method. A
java.lang.IllegalStateException is thrown if this instance has
not been initialized, and it is up to the programmer to ensure that
there is one full block in in starting at inOffset, and
enough space for one full block in out starting at
outOffset. Since modes can have states, and may require that the
be used in a particular sequence, using this method is preferred over
the encryptBlock and decryptBlock methods of
IBlockCipher.