gnu.javax.crypto.mode
Interface IMode
- Cloneable, IBlockCipher
- IAuthenticatedMode
- BaseMode, CBC, CFB, CTR, EAX, ECB, ICM, OFB
The basic visible methods of any block cipher mode.
Block ciphers encrypt plaintext in fixed size n-bit blocks. For messages
larger than n bits, the simplest approach is to segment the message into
n-bit blocks and process (encrypt and/or decrypt) each one separately
(Electronic Codebook or ECB mode). But this approach has disadvantages in
most applications. The block cipher modes of operations are one way of
working around those disadvantages.
A
Mode always employs an underlying block cipher for processing its
input. For all intents and purposes, a
Mode appears to behave as any
other block cipher with the following differences:
- Depending on the specifications of the mode, the block size may be
different that that of the underlying cipher.
- While some modes of operations allow operations on block sizes that can
be 1-bit long, this library will only deal with sizes that are multiple of 8
bits. This is because the byte is the smallest, easy to handle,
primitive type in Java.
- Some modes need an Initialisation Vector (IV) to be properly
initialised.
Possible additional initialisation values for an instance of that type are:
- The block size in which to operate this mode instance. This value is
optional, if unspecified, the underlying block cipher's configured
block size shall be used.
- Whether this mode will be used for encryption or decryption. This value
is mandatory and should be included in the initialisation parameters.
If it isn't, a
IllegalStateException
will be thrown if any
method, other than reset()
is invoked on the instance. - The byte array containing the initialisation vector, if required
by this type of mode.
static int | DECRYPTION - Constant indicating the instance is being used for decryption.
|
static int | ENCRYPTION - Constant indicating the instance is being used for encryption.
|
static String | IV - Property name of the initialisation vector to use, if required, with this
instance.
|
static String | MODE_BLOCK_SIZE - Property name of the block size in which to operate this mode.
|
static String | STATE - Property name of the state in which to operate this mode.
|
void | update(byte[] in, int inOffset, byte[] out, int outOffset) - A convenience method.
|
blockSizes , clone , currentBlockSize , decryptBlock , defaultBlockSize , defaultKeySize , encryptBlock , init , keySizes , name , reset , selfTest |
DECRYPTION
public static final int DECRYPTION
Constant indicating the instance is being used for decryption.
ENCRYPTION
public static final int ENCRYPTION
Constant indicating the instance is being used for encryption.
IV
public static final String IV
Property name of the initialisation vector to use, if required, with this
instance. The value associated with this property name is taken to be a
byte array. If the concrete instance needs such a parameter, and it has not
been specified as part of the initialissation parameters, an all-zero byte
array of the appropriate size shall be used.
MODE_BLOCK_SIZE
public static final String MODE_BLOCK_SIZE
Property name of the block size in which to operate this mode. The value
associated with this property name is taken to be an
Integer
. If
it is not specified, the value of the block size of the underlying block
cipher, used to construct the mode instance, shall be used.
- "gnu.crypto.mode.block.size"
STATE
public static final String STATE
Property name of the state in which to operate this mode. The value
associated to this property name is taken to be an
Integer
which
value is either
ENCRYPTION
or
DECRYPTION
.
update
public void update(byte[] in,
int inOffset,
byte[] out,
int outOffset)
throws IllegalStateException
A convenience method. Effectively invokes the encryptBlock()
or decryptBlock()
method depending on the operational state
of the instance.
in
- the plaintext.inOffset
- index of in
from which to start considering
data.out
- the ciphertext.outOffset
- index of out
from which to store result.
IMode.java --
Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
This file is a part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.