The Cipher Engine
First, we’ll look at the
engine that performs encryption within
JCE. This engine is called the Cipher
class
(javax.crypto.Cipher
); it provides an interface
to encrypt and decrypt data either in arrays within the program or as
that data is read or written through Java’s stream interfaces:
- public class Cipher implements Cloneable
Perform encryption and decryption of arbitrary data, using (potentially) a wide array of encryption algorithms.
Like all security engines, the cipher engine implements named
algorithms. However, the naming convention for the cipher engine is
different in that cipher algorithms are compound names that can
include the name of the algorithm along with the name of a padding
scheme and the name of a mode.
Padding schemes and modes are
specified by names -- just like algorithms. In theory, just as you
may pick a new name for an algorithm, you may specify new names for a
padding scheme or a mode, although the SunJCE
security provider specifies several standard ones.
Modes and padding schemes are present in the
Cipher
class because that class implements what
is known as a block cipher; that is, it expects to operate on data
one block (e.g., 8 bytes) at a time. Padding schemes are required in
order to ensure that the length of the data is an integral number of
blocks.
Modes are provided to further alter the encrypted data in an attempt to make it harder to break the encryption. For example, if the data to be encrypted contains a number of similar ...
Get Java Security, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.