com.motorola.iden.provider
Class DESede

java.lang.Object
  |
  +--com.motorola.iden.crypto.CipherSpi
        |
        +--com.motorola.iden.provider.DESede

public final class DESede
extends CipherSpi

DESede was written by IBM and first released in 1976. The algorithm is freely usable for both single and triple encryption.

DESede is a block cipher with an 8 byte block size. The key length is 24 bytes for triple encryption. The parity of all DESede keys is ignored.

For triple encryption, please use algorithm name "DESede". Interface com.motorola.iden.security.Key must be implemented by end user.

DESede support mode "ECB","CBC","CFB" and "OFB". OFB mode is not supported on Gemini. Mode "CBC","CFB" and "OFB" have IV. IV can be initialized by user or generated by system. PKCS5Padding is supported by default.

MOTOROLA and the Stylized M Logo are registered trademarks of Motorola, Inc. Reg. U.S. Pat. & Tm. Off.
© Copyright 2002 - 2004 Motorola, Inc. All Rights Reserved.

See Also:
[CipherSpi]

Field Summary
static int blocksize
          The blocksize of DES.
 
Constructor Summary
DESede()
           
 
Method Summary
protected  byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
          Finalizes cipher.
protected  int engineGetBlockSize()
          Gets the bloksize of the cipher.
protected  byte[] engineGetIV()
          Gets iv.
protected  void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)
          Initializes security builder.
protected  void engineSetMode(java.lang.String mode)
          Sets the mode of the cipher(ECB,CBC,CFB or OFB).
protected  void engineSetPadding(java.lang.String padding)
          Sets the Padding of the cipher.
protected  byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
          Updates cipher.
protected  void finalize()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blocksize

public static final int blocksize
The blocksize of DES.

DES is a block cipher with an 8 byte block size.
Constructor Detail

DESede

public DESede()
Method Detail

engineSetMode

protected void engineSetMode(java.lang.String mode)
                      throws NoSuchAlgorithmException
Sets the mode of the cipher(ECB,CBC,CFB or OFB).
Overrides:
engineSetMode in class CipherSpi
Parameters:
String - mode. Mode ECB is set defaultly when parameter mode is null.
Returns:
void.
Throws:
NoSuchAlgorithmException - if the requested mode mechanism does not exist

engineSetPadding

protected void engineSetPadding(java.lang.String padding)
                         throws NoSuchPaddingException
Sets the Padding of the cipher.
Overrides:
engineSetPadding in class CipherSpi
Parameters:
String - padding. PKCS5Padding is set defaultly when parameter padding is null.
Throws:
NoSuchPaddingException - if the requested padding mechanism does not exist

engineGetBlockSize

protected int engineGetBlockSize()
Gets the bloksize of the cipher.
Overrides:
engineGetBlockSize in class CipherSpi
Parameters:
viod. -  
Returns:
int blocksize (bytes)..

engineGetIV

protected byte[] engineGetIV()
Gets iv.
Overrides:
engineGetIV in class CipherSpi
Returns:
byte[] iv. (null when at mode ECB)

engineInit

protected void engineInit(int opmode,
                          Key key,
                          AlgorithmParameterSpec params,
                          SecureRandom random)
                   throws InvalidKeyException,
                          InvalidAlgorithmParameterException
Initializes security builder.
Overrides:
engineInit in class CipherSpi
Parameters:
opmode - the operation mode of this cipher (this is one of the following: ENCRYPT_MODE, DECRYPT_MODE,
key - the encryption key
params - the algorithm parameters
random - the source of randomness, ignored in this implementation.
Returns:
void.
Throws:
InvalidKeyException - if the given key is inappropriate for initializing this cipher
InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this cipher, or if this cipher is being initialized for decryption and requires algorithm parameters and params is null.

engineUpdate

protected byte[] engineUpdate(byte[] input,
                              int inputOffset,
                              int inputLen)
Updates cipher.
Overrides:
engineUpdate in class CipherSpi
Parameters:
input - the input buffer
inputOffset - the offset in input where the input starts
inputLen - the input length
Returns:
the new buffer with the result, or null if the underlying cipher is a block cipher and the input data is too short to result in a new block.

engineDoFinal

protected byte[] engineDoFinal(byte[] input,
                               int inputOffset,
                               int inputLen)
                        throws IllegalBlockSizeException,
                               BadPaddingException
Finalizes cipher.
Overrides:
engineDoFinal in class CipherSpi
Parameters:
input - the input buffer
inputOffset - the offset in input where the input starts
inputLen - the input length
Returns:
the new buffer with the result
Throws:
IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size
BadPaddingException - if this cipher is in decryption mode, and (un)padding has been requested, but the decrypted data is not bounded by the appropriate padding bytes

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object