gnu.crypto.mode
Class BaseMode
- Cloneable, IBlockCipher, IMode
public abstract class BaseMode
extends java.lang.Object
A basic abstract class to facilitate implementing block cipher modes of
operations.
Version:
protected IBlockCipher | cipher - The underlying block cipher implementation.
|
protected int | cipherBlockSize - The block size, in bytes, to operate the underlying block cipher in.
|
protected byte[] | iv - The initialisation vector value.
|
protected Object | lock - The instance lock.
|
protected int | modeBlockSize - The block size, in bytes, in which to operate the mode instance.
|
protected String | name - The canonical name prefix of this mode.
|
protected int | state - The state indicator of this instance.
|
BaseMode(String name, IBlockCipher underlyingCipher, int cipherBlockSize) - Trivial constructor for use by concrete subclasses.
|
Iterator | blockSizes() - Returns an
Iterator over the supported block sizes.
|
Object | clone()
|
int | currentBlockSize()
|
void | decryptBlock(byte[] in, int i, byte[] out, int o)
|
int | defaultBlockSize() - Returns the default value, in bytes, of the mode's block size.
|
int | defaultKeySize() - Returns the default value, in bytes, of the underlying block cipher
key size.
|
void | encryptBlock(byte[] in, int i, byte[] out, int o)
|
void | init(Map attributes)
|
Iterator | keySizes() - Returns an
Iterator over the supported underlying block cipher
key sizes.
|
String | name()
|
void | reset()
|
boolean | selfTest()
|
void | setup() - The initialisation phase of the concrete mode implementation.
|
void | teardown() - The termination phase of the concrete mode implementation.
|
void | update(byte[] in, int inOffset, byte[] out, int outOffset)
|
cipher
protected IBlockCipher cipher
The underlying block cipher implementation.
cipherBlockSize
protected int cipherBlockSize
The block size, in bytes, to operate the underlying block cipher in.
iv
protected byte[] iv
The initialisation vector value.
lock
protected Object lock
The instance lock.
modeBlockSize
protected int modeBlockSize
The block size, in bytes, in which to operate the mode instance.
name
protected String name
The canonical name prefix of this mode.
state
protected int state
The state indicator of this instance.
BaseMode
protected BaseMode(String name,
IBlockCipher underlyingCipher,
int cipherBlockSize)
Trivial constructor for use by concrete subclasses.
name
- the canonical name prefix of this mode.underlyingCipher
- the implementation of the underlying cipher.cipherBlockSize
- the block size, in bytes, in which to operate the
underlying cipher.
blockSizes
public Iterator blockSizes()
Returns an
Iterator
over the supported block sizes. Each
element returned by this object is an
Integer
.
The default behaviour is to return an iterator with just one value,
which is that currently configured for the underlying block cipher.
Concrete implementations may override this behaviour to signal their
ability to support other values.
- blockSizes in interface IBlockCipher
- an
Iterator
over the supported block sizes.
defaultBlockSize
public int defaultBlockSize()
Returns the default value, in bytes, of the mode's block size. This
value is part of the construction arguments passed to the Factory methods
in
ModeFactory
. Unless changed by an invocation of any of the
init()
methods, a
Mode instance would operate with
the same block size as its underlying block cipher. As mentioned earlier,
the block size of the underlying block cipher itself is specified in one
of the method(s) available in the factory class.
- defaultBlockSize in interface IBlockCipher
- the default value, in bytes, of the mode's block size.
ModeFactory
defaultKeySize
public int defaultKeySize()
Returns the default value, in bytes, of the underlying block cipher
key size.
- defaultKeySize in interface IBlockCipher
- the default value, in bytes, of the underlying cipher's key size.
init
public void init(Map attributes)
throws InvalidKeyException,
IllegalStateException
- init in interface IBlockCipher
keySizes
public Iterator keySizes()
Returns an Iterator
over the supported underlying block cipher
key sizes. Each element returned by this object is an instance of
Integer
.
- keySizes in interface IBlockCipher
- an
Iterator
over the supported key sizes.
setup
public void setup()
The initialisation phase of the concrete mode implementation.
teardown
public void teardown()
The termination phase of the concrete mode implementation.
update
public void update(byte[] in,
int inOffset,
byte[] out,
int outOffset)
throws IllegalStateException
- update in interface IMode
Copyright © 2001, 2002, 2003
Free Software Foundation,
Inc. All Rights Reserved.