gnu.crypto.jce.cipher

Class CipherAdapter

Known Direct Subclasses:
AESSpi, AnubisSpi, BlowfishSpi, Cast5Spi, DESSpi, KhazadSpi, NullCipherSpi, PBES2, RijndaelSpi, SerpentSpi, SquareSpi, TripleDESSpi, TwofishSpi

(package private) 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(String) constructor with the name of the cipher.

Version:
$Revision: 1.3 $

Field Summary

protected Map
attributes
Our attributes map.
protected int
blockLen
The length of blocks we are processing.
protected IBlockCipher
cipher
Our cipher instance.
protected int
keyLen
The current key size.
protected IMode
mode
Our mode instance.
protected IPad
pad
Our padding instance.
protected byte[]
partBlock
An incomplete block.
protected int
partLen
The number of bytes in partBlock.

Constructor Summary

CipherAdapter(String cipherName)
Creates a new cipher adapter with the default block size.
CipherAdapter(String cipherName, int blockLen)
Protected constructor to be called by subclasses.

Method Summary

protected byte[]
engineDoFinal(byte[] input, int off, int len)
protected int
engineDoFinal(byte[] in, int inOff, int inLen, byte[] out, int outOff)
protected int
engineGetBlockSize()
protected byte[]
engineGetIV()
protected int
engineGetOutputSize(int inputLen)
protected AlgorithmParameters
engineGetParameters()
protected void
engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)
protected void
engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random)
protected void
engineInit(int opmode, Key key, SecureRandom random)
protected void
engineSetMode(String modeName)
protected void
engineSetPadding(String padName)
protected byte[]
engineUpdate(byte[] input, int off, int len)
protected int
engineUpdate(byte[] in, int inOff, int inLen, byte[] out, int outOff)

Field Details

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

Constructor Details

CipherAdapter

protected CipherAdapter(String cipherName)
Creates a new cipher adapter with the default block size.

Parameters:
cipherName - The cipher to instantiate.


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.

Method Details

engineDoFinal

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


engineDoFinal

protected int engineDoFinal(byte[] in,
                            int inOff,
                            int inLen,
                            byte[] out,
                            int outOff)
            throws BadPaddingException,
                   IllegalBlockSizeException,
                   ShortBufferException


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,
                          AlgorithmParameterSpec params,
                          SecureRandom random)
            throws InvalidKeyException,
                   InvalidAlgorithmParameterException


engineInit

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


engineInit

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


engineSetMode

protected void engineSetMode(String modeName)
            throws NoSuchAlgorithmException


engineSetPadding

protected void engineSetPadding(String padName)
            throws NoSuchPaddingException


engineUpdate

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


engineUpdate

protected int engineUpdate(byte[] in,
                           int inOff,
                           int inLen,
                           byte[] out,
                           int outOff)
            throws ShortBufferException


Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.