de.flexiprovider.core.misty1
Class Misty1

java.lang.Object
  |
  +--javax.crypto.CipherSpi
        |
        +--de.flexiprovider.api.Cipher
              |
              +--de.flexiprovider.api.BlockCipher
                    |
                    +--de.flexiprovider.core.misty1.Misty1

public class Misty1
extends BlockCipher

Misty1 is 64-bit symmetric block cipher with a Feistel structure, jointly developed by Matsui Mitsuru, Ichikawa Tetsuya, Sorimachi Toru, Tokita Toshio, and Yamagishi Atsuhiro for the Mitsubishi Electric Corporation. It supports 128 bit keys. Encrypting and decryption of a block of data is achieved in 8 rounds (more generally a multiple of 4 rounds). For more information, see here.

Author:
Paul Nguentcheu

Field Summary
static java.lang.String ALG_NAME
          The algorithm name.
 
Fields inherited from class de.flexiprovider.api.BlockCipher
random
 
Fields inherited from class de.flexiprovider.api.Cipher
DECRYPT_MODE, ENCRYPT_MODE, opMode
 
Constructor Summary
Misty1()
           
 
Method Summary
protected  int getCipherBlockSize()
          This method returns the blocksize, the algorithm uses.
 int getKeySize(Key key)
          Returns the key size of the given key object.
 java.lang.String getName()
           
protected  void initCipherDecrypt(SecretKey key, AlgorithmParameterSpec params)
          This method initializes the block cipher with a given key for data decryption.
protected  void initCipherEncrypt(SecretKey key, AlgorithmParameterSpec params)
          This method initializes the block cipher with a given key for data encryption.
protected  void singleBlockDecrypt(byte[] input, int inOff, byte[] output, int outOff)
          This method decrypts a single block of data.
protected  void singleBlockEncrypt(byte[] input, int inOff, byte[] output, int outOff)
          This method encrypts 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.
Constructor Detail

Misty1

public Misty1()
Method Detail

getName

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

getCipherBlockSize

protected final int getCipherBlockSize()
This method returns the blocksize, the algorithm uses. This method will normaly be called by the padding scheme. It must be assured, that this method is exclusivly called, when the algorithm is either in encryption or in decryption mode. The blocksize in misty-1 is always 8 bytes.
Overrides:
getCipherBlockSize in class BlockCipher
Returns:
the used blocksize

getKeySize

public int getKeySize(Key key)
               throws InvalidKeyException
Returns the key size of the given key object. Checks whether the key object is an instance of Misty1Key or SecretKeySpec and whether the key size is within the specified range for Misty1. Only 128 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.

initCipherEncrypt

protected final void initCipherEncrypt(SecretKey key,
                                       AlgorithmParameterSpec params)
                                throws InvalidKeyException
This method initializes the block cipher with a given key for data encryption.
Overrides:
initCipherEncrypt in class BlockCipher
Parameters:
key - SecretKey to be used to encrypt data
params - AlgorithmParamterSpec to be used with this algorithm
Throws:
InvalidKeyException - if the given key is illegal for this cipher

initCipherDecrypt

protected final void initCipherDecrypt(SecretKey key,
                                       AlgorithmParameterSpec params)
                                throws InvalidKeyException
This method initializes the block cipher with a given key for data decryption.
Overrides:
initCipherDecrypt in class BlockCipher
Parameters:
key - SecretKey to be used to decrypt data
params - AlgorithmParamterSpec to be used with this algorithm
Throws:
InvalidKeyException - if the given key is illegal for this cipher

singleBlockEncrypt

protected final void singleBlockEncrypt(byte[] input,
                                        int inOff,
                                        byte[] output,
                                        int outOff)
This method encrypts a single block of data. The array in must contain a whole block starting at inOffset and out must be large enough to hold an encrypted block starting at outOffset.
Overrides:
singleBlockEncrypt in class BlockCipher
Parameters:
input - array of bytes containing the plaintext to be encrypted
inOff - index in array in, where the plaintext block starts
output - array of bytes which will contain the ciphertext starting at outOffset
outOff - index in array out, where the ciphertext block will start

singleBlockDecrypt

protected final void singleBlockDecrypt(byte[] input,
                                        int inOff,
                                        byte[] output,
                                        int outOff)
This method decrypts a single block of data. The array in must contain a whole block starting at inOffset and out must be large enough to hold an encrypted block starting at outOffset.
Overrides:
singleBlockDecrypt in class BlockCipher
Parameters:
input - array of bytes containig 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