de.flexiprovider.core.rijndael
Class Rijndael

java.lang.Object
  |
  +--javax.crypto.CipherSpi
        |
        +--de.flexiprovider.api.Cipher
              |
              +--de.flexiprovider.api.BlockCipher
                    |
                    +--de.flexiprovider.core.rijndael.Rijndael
Direct Known Subclasses:
Rijndael.AES

public class Rijndael
extends BlockCipher

This class implements the Rijndael block cipher. Rijndael uses a block size of 16, 24 or 32 bytes. The key size can be 16, 24 or 32 bytes. Encryption/decryption takes 32 rounds. For more information, see http://csrc.nist.gov/archive/aes/index.html.

Author:
Katja Rauch

Inner Class Summary
static class Rijndael.AES
           
 
Field Summary
static java.lang.String ALG_NAME
          The algorithm name.
protected  java.lang.String algName
          The algorithm name returned by getName().
protected  int blockSize
          the block length in words (word width is 32 bits)
protected  boolean blockSizeIsMutable
          flag indicating whether block length may be changed
protected  int keySize
          the key size in words (word width is 32 bits)
protected  boolean keySizeIsMutable
          flag indicating whether key size may be changed
 
Fields inherited from class de.flexiprovider.api.BlockCipher
random
 
Fields inherited from class de.flexiprovider.api.Cipher
DECRYPT_MODE, ENCRYPT_MODE, opMode
 
Constructor Summary
Rijndael()
          Constructor.
 
Method Summary
protected  int getCipherBlockSize()
          Return the blocksize the algorithm uses.
 int getKeySize(Key key)
          Return the key size of the given key object.
 java.lang.String getName()
           
protected  void initCipherDecrypt(SecretKey key, AlgorithmParameterSpec params)
          Initialize the block cipher with a given key and parameters for data decryption.
protected  void initCipherEncrypt(SecretKey key, AlgorithmParameterSpec params)
          Initialize the block cipher with a given key and parameters for data encryption.
protected  void singleBlockDecrypt(byte[] input, int inOff, byte[] output, int outOff)
          Decrypt a single block of data.
protected  void singleBlockEncrypt(byte[] input, int inOff, byte[] output, int outOff)
          Encrypt a single block of data.
 
Methods inherited from class de.flexiprovider.api.BlockCipher
doFinal, doFinal, engineInit, getBlockSize, getIV, getOutputSize, getParameters, initDecrypt, initDecrypt, initDecrypt, initEncrypt, initEncrypt, initEncrypt, initEncrypt, setMode, setPadding, update, update
 
Methods inherited from class de.flexiprovider.api.Cipher
doFinal, doFinal, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate, update
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALG_NAME

public static final java.lang.String ALG_NAME
The algorithm name.

algName

protected java.lang.String algName
The algorithm name returned by getName().

keySize

protected int keySize
the key size in words (word width is 32 bits)

keySizeIsMutable

protected boolean keySizeIsMutable
flag indicating whether key size may be changed

blockSize

protected int blockSize
the block length in words (word width is 32 bits)

blockSizeIsMutable

protected boolean blockSizeIsMutable
flag indicating whether block length may be changed
Constructor Detail

Rijndael

public Rijndael()
Constructor.
Method Detail

getName

public final java.lang.String getName()
Overrides:
getName in class Cipher
Returns:
the name of this cipher

getKeySize

public int getKeySize(Key key)
               throws InvalidKeyException
Return the key size of the given key object. Check whether the key object is an instance of RijndaelKey and whether the key size is valid for Rijndael. 128, 192 and 256 bit keys are allowed.
Overrides:
getKeySize in class Cipher
Parameters:
key - the key object
Returns:
the key size of the given key object.
Throws:
InvalidKeyException - if key is invalid.

getCipherBlockSize

protected int getCipherBlockSize()
Description copied from class: BlockCipher
Return the blocksize the algorithm uses. This method will usually be called by the mode.
Overrides:
getCipherBlockSize in class BlockCipher
Returns:
the block size (in bytes)

initCipherEncrypt

protected void initCipherEncrypt(SecretKey key,
                                 AlgorithmParameterSpec params)
                          throws InvalidKeyException,
                                 InvalidAlgorithmParameterException
Initialize the block cipher with a given key and parameters for data encryption.
Overrides:
initCipherEncrypt in class BlockCipher
Parameters:
key - SecretKey to be used to encrypt data
params - AlgorithmParameterSpec to be used with this algorithm. Only instances of RijndaelParameterSpec are allowed.
Throws:
InvalidKeyException - if the given key is illegal for this cipher.
InvalidAlgorithmParameterException - if the parameters are illegal for this cipher.

initCipherDecrypt

protected void initCipherDecrypt(SecretKey key,
                                 AlgorithmParameterSpec params)
                          throws InvalidKeyException,
                                 InvalidAlgorithmParameterException
Initialize the block cipher with a given key and parameters for data decryption.
Overrides:
initCipherDecrypt in class BlockCipher
Parameters:
key - SecretKey to be used to decrypt data
params - AlgorithmParameterSpec to be used with this algorithm. Only instances of RijndaelParameterSpec are allowed.
Throws:
InvalidKeyException - if the given key is illegal for this cipher.
InvalidAlgorithmParameterException - if the parameters are illegal for this cipher.

singleBlockEncrypt

protected void singleBlockEncrypt(byte[] input,
                                  int inOff,
                                  byte[] output,
                                  int outOff)
Encrypt a single block of data.
Overrides:
singleBlockEncrypt in class BlockCipher
Parameters:
input - byte array containing the plaintext block to be encrypted
inOff - index where the plaintext block starts
output - byte array to hold the ciphertext block
outOff - index where the ciphertext block will start

singleBlockDecrypt

protected void singleBlockDecrypt(byte[] input,
                                  int inOff,
                                  byte[] output,
                                  int outOff)
Decrypt a single block of data.
Overrides:
singleBlockDecrypt in class BlockCipher
Parameters:
input - byte array containing the ciphertext block to be decrypted
inOff - index where the ciphertext block starts
output - byte array to hold the plaintext block
outOff - index where the plaintext block will start