gnu.crypto.mode

Class BaseMode

public abstract class BaseMode extends Object implements IMode

A basic abstract class to facilitate implementing block cipher modes of operations.

Version: $Revision: 1.7 $

Field Summary
protected IBlockCiphercipher
The underlying block cipher implementation.
protected intcipherBlockSize
The block size, in bytes, to operate the underlying block cipher in.
protected byte[]iv
The initialisation vector value.
protected Objectlock
The instance lock.
protected intmodeBlockSize
The block size, in bytes, in which to operate the mode instance.
protected Stringname
The canonical name prefix of this mode.
protected intstate
The state indicator of this instance.
Constructor Summary
protected BaseMode(String name, IBlockCipher underlyingCipher, int cipherBlockSize)

Trivial constructor for use by concrete subclasses.

Method Summary
IteratorblockSizes()

Returns an Iterator over the supported block sizes.

abstract Objectclone()
intcurrentBlockSize()
abstract voiddecryptBlock(byte[] in, int i, byte[] out, int o)
intdefaultBlockSize()

Returns the default value, in bytes, of the mode's block size.

intdefaultKeySize()

Returns the default value, in bytes, of the underlying block cipher key size.

abstract voidencryptBlock(byte[] in, int i, byte[] out, int o)
voidinit(Map attributes)
IteratorkeySizes()

Returns an Iterator over the supported underlying block cipher key sizes.

Stringname()
voidreset()
booleanselfTest()
abstract voidsetup()
The initialisation phase of the concrete mode implementation.
abstract voidteardown()
The termination phase of the concrete mode implementation.
voidupdate(byte[] in, int inOffset, byte[] out, int outOffset)

Field Detail

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.

Constructor Detail

BaseMode

protected BaseMode(String name, IBlockCipher underlyingCipher, int cipherBlockSize)

Trivial constructor for use by concrete subclasses.

Parameters: 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.

Method Detail

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.

Returns: an Iterator over the supported block sizes.

clone

public abstract Object clone()

currentBlockSize

public int currentBlockSize()

decryptBlock

public abstract void decryptBlock(byte[] in, int i, byte[] out, int o)

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.

Returns: the default value, in bytes, of the mode's block size.

See Also: ModeFactory

defaultKeySize

public int defaultKeySize()

Returns the default value, in bytes, of the underlying block cipher key size.

Returns: the default value, in bytes, of the underlying cipher's key size.

encryptBlock

public abstract void encryptBlock(byte[] in, int i, byte[] out, int o)

init

public void init(Map attributes)

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.

Returns: an Iterator over the supported key sizes.

name

public String name()

reset

public void reset()

selfTest

public boolean selfTest()

setup

public abstract void setup()
The initialisation phase of the concrete mode implementation.

teardown

public abstract void teardown()
The termination phase of the concrete mode implementation.

update

public void update(byte[] in, int inOffset, byte[] out, int outOffset)
Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.