de.flexiprovider.core.idea
Class IDEA

java.lang.Object
  |
  +--javax.crypto.CipherSpi
        |
        +--de.flexiprovider.api.Cipher
              |
              +--de.flexiprovider.api.BlockCipher
                    |
                    +--de.flexiprovider.core.idea.IDEA
Direct Known Subclasses:
IDEA.IDEA_CBC, IDEA.IDEA_CFB, IDEA.IDEA_ECB, IDEA.IDEA_OFB

public class IDEA
extends BlockCipher

BlockCipherIDEA implements the IDEA Cipher. It uses a block size of 64 (8 Bytes), a 128 bit key and uses 8 rounds for encryption/decryption.

Author:
Ralph Kuhnert, Anders Adamson, Oliver Seiler

Inner Class Summary
static class IDEA.IDEA_CBC
          IDEA_CBC
static class IDEA.IDEA_CFB
          IDEA_CFB
static class IDEA.IDEA_ECB
          IDEA_ECB
static class IDEA.IDEA_OFB
          IDEA_OFB
 
Field Summary
static java.lang.String ALG_NAME
          The algorithm name.
static java.lang.String OID
          The OID of IDEA.
 
Fields inherited from class de.flexiprovider.api.BlockCipher
random
 
Fields inherited from class de.flexiprovider.api.Cipher
DECRYPT_MODE, ENCRYPT_MODE, opMode
 
Constructor Summary
  IDEA()
          Constructor.
protected IDEA(java.lang.String modeName)
           
 
Method Summary
protected  int getCipherBlockSize()
          Return the blocksize the algorithm uses.
 int getKeySize(Key key)
          Return the key size in bits of the given key object.
 java.lang.String getName()
           
protected  void initCipherDecrypt(SecretKey key, AlgorithmParameterSpec params)
          This method guarantees the AlgorithmParameterSpec compatibility.
protected  void initCipherEncrypt(SecretKey key, AlgorithmParameterSpec params)
          This method guarantees the AlgorithmParameterSpec compatibility.
protected  void singleBlockDecrypt(byte[] input, int inOff, byte[] output, int outOff)
          This method decrypts a single block of data, and may only be called, if the block cipher is in decrytion mode.
protected  void singleBlockEncrypt(byte[] input, int inOff, byte[] output, int outOff)
          This method encrypts a single block of data, and may only be called, if the block cipher is in encrytion mode.
 
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.

OID

public static final java.lang.String OID
The OID of IDEA.
Constructor Detail

IDEA

protected IDEA(java.lang.String modeName)

IDEA

public IDEA()
Constructor.
Method Detail

getName

public 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 in bits of the given key object. Checks whether the key object is an instance of IDEAKey or SecretKeySpec. The key size for IDEA is always fixed to 128 bits as per the specification.
Overrides:
getKeySize in class Cipher
Parameters:
key - the key object
Returns:
the key size in bits 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 of the cipher

initCipherEncrypt

protected void initCipherEncrypt(SecretKey key,
                                 AlgorithmParameterSpec params)
                          throws InvalidKeyException
This method guarantees the AlgorithmParameterSpec compatibility. As these are not used here it just calls the origin InitDecrypt method.
Overrides:
initCipherEncrypt in class BlockCipher
Parameters:
key - the SecretKey which has to be used to decrypt data.
params - algorithmParameterSpec, not used for here
Throws:
InvalidKeyException - if the given key is inappropriate for initialising this cipher.

initCipherDecrypt

protected void initCipherDecrypt(SecretKey key,
                                 AlgorithmParameterSpec params)
                          throws InvalidKeyException
This method guarantees the AlgorithmParameterSpec compatibility. As these are not used here it just calls the origin InitDecrypt method.
Overrides:
initCipherDecrypt in class BlockCipher
Parameters:
key - the SecretKey which has to be used to decrypt data.
params - algorithmParameterSpec, not used for here
Throws:
InvalidKeyException - if the given key is inappropriate for initialising this cipher.

singleBlockEncrypt

protected void singleBlockEncrypt(byte[] input,
                                  int inOff,
                                  byte[] output,
                                  int outOff)
This method encrypts a single block of data, and may only be called, if the block cipher is in encrytion mode. It has to be asured that the array in contains a whole block starting at inOffset and that out is large enough to hold an encrypted block starting at outOffset
Overrides:
singleBlockEncrypt in class BlockCipher
Parameters:
input - array of bytes which contains the plaintext to be encrypted
inOff - index in array in, where the plaintext block starts
output - array of bytes which will contain the ciphertext startig at outOffset
outOff - index in array out, where the ciphertext block will start

singleBlockDecrypt

protected void singleBlockDecrypt(byte[] input,
                                  int inOff,
                                  byte[] output,
                                  int outOff)
This method decrypts a single block of data, and may only be called, if the block cipher is in decrytion mode. It has to be asured that the array in contains a whole block starting at inOffset and that out is large enough to hold an decrypted block starting at outOffset
Overrides:
singleBlockDecrypt in class BlockCipher
Parameters:
input - array of bytes which contains the ciphertext to be decrypted
inOff - index in array in, where the ciphertext block starts
output - array of bytes which will contain the plaintext starting at outOffset
outOff - index in array out, where the plaintext block will start