gnu.crypto.jce.cipher

Class CipherAdapter

class CipherAdapter extends CipherSpi

The implementation of a generic Cipher Adapter class to wrap GNU Crypto cipher instances.

This class defines the Service Provider Interface (SPI) for the Cipher class, which provides the functionality of symmetric-key block ciphers, such as the AES.

This base class defines all of the abstract methods in CipherSpi, but does not define the (non-abstract) key wrapping functions that extended the base cipher SPI, and these methods thus immediately throw an UnsupportedOperationException. If a cipher implementation provides this functionality, or if it in fact accepts parameters other than the key and the initialization vector, the subclass should override those methods. Otherwise a subclass need only call the CipherAdapter constructor with the name of the cipher.

Version: $Revision: 1.5 $

Field Summary
protected Mapattributes
Our attributes map.
protected intblockLen
The length of blocks we are processing.
protected IBlockCiphercipher
Our cipher instance.
protected intkeyLen
The current key size.
protected IModemode
Our mode instance.
protected IPadpad
Our padding instance.
protected byte[]partBlock
An incomplete block.
protected intpartLen
The number of bytes in partBlock.
Constructor Summary
protected CipherAdapter(String cipherName, int blockLen)

Protected constructor to be called by subclasses.

protected CipherAdapter(String cipherName)

Creates a new cipher adapter with the default block size.

Method Summary
protected byte[]engineDoFinal(byte[] input, int off, int len)
protected intengineDoFinal(byte[] in, int inOff, int inLen, byte[] out, int outOff)
protected intengineGetBlockSize()
protected byte[]engineGetIV()
protected intengineGetOutputSize(int inputLen)
protected AlgorithmParametersengineGetParameters()
protected voidengineInit(int opmode, Key key, SecureRandom random)
protected voidengineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)
protected voidengineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random)
protected voidengineSetMode(String modeName)
protected voidengineSetPadding(String padName)
protected byte[]engineUpdate(byte[] input, int off, int len)
protected intengineUpdate(byte[] in, int inOff, int inLen, byte[] out, int outOff)

Field Detail

attributes

protected Map attributes
Our attributes map.

blockLen

protected int blockLen
The length of blocks we are processing.

cipher

protected IBlockCipher cipher
Our cipher instance.

keyLen

protected int keyLen
The current key size.

mode

protected IMode mode
Our mode instance.

pad

protected IPad pad
Our padding instance.

partBlock

protected byte[] partBlock
An incomplete block.

partLen

protected int partLen
The number of bytes in partBlock.

Constructor Detail

CipherAdapter

protected CipherAdapter(String cipherName, int blockLen)

Protected constructor to be called by subclasses. The cipher name argument should be the appropriate one listed in Registry. The basic cipher instance is created, along with an instance of the ECB mode and no padding.

Parameters: cipherName The cipher to instantiate. blockLen The block length to use.

CipherAdapter

protected CipherAdapter(String cipherName)

Creates a new cipher adapter with the default block size.

Parameters: cipherName The cipher to instantiate.

Method Detail

engineDoFinal

protected byte[] engineDoFinal(byte[] input, int off, int len)

engineDoFinal

protected int engineDoFinal(byte[] in, int inOff, int inLen, byte[] out, int outOff)

engineGetBlockSize

protected int engineGetBlockSize()

engineGetIV

protected byte[] engineGetIV()

engineGetOutputSize

protected int engineGetOutputSize(int inputLen)

engineGetParameters

protected AlgorithmParameters engineGetParameters()

engineInit

protected void engineInit(int opmode, Key key, SecureRandom random)

engineInit

protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)

engineInit

protected void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random)

engineSetMode

protected void engineSetMode(String modeName)

engineSetPadding

protected void engineSetPadding(String padName)

engineUpdate

protected byte[] engineUpdate(byte[] input, int off, int len)

engineUpdate

protected int engineUpdate(byte[] in, int inOff, int inLen, byte[] out, int outOff)
Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.