Save This Page
Home » openjdk-7 » com.sun.crypto » provider » [javadoc | source]
com.sun.crypto.provider
public final class: PBEWithMD5AndTripleDESCipher [javadoc | source]
java.lang.Object
   javax.crypto.CipherSpi
      com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher
This class implements a proprietary password-based encryption algorithm. It is based on password-based encryption as defined by the PKCS #5 standard, except that is uses triple DES instead of DES. Here's how this algorithm works: 1. Create random salt and split it in two halves. If the two halves are identical, invert one of them. 2. Concatenate password with each of the halves. 3. Digest each concatenation with c iterations, where c is the iterationCount. Concatenate the output from each digest round with the password, and use the result as the input to the next digest operation. The digest algorithm is MD5. 4. After c iterations, use the 2 resulting digests as follows: The 16 bytes of the first digest and the 1st 8 bytes of the 2nd digest form the triple DES key, and the last 8 bytes of the 2nd digest form the IV.
Constructor:
 public PBEWithMD5AndTripleDESCipher() throws NoSuchAlgorithmException, NoSuchPaddingException 
    Creates an instance of this cipher, and initializes its mode (CBC) and padding (PKCS5).
    Throws:
    NoSuchAlgorithmException - if the required cipher mode (CBC) is unavailable
    NoSuchPaddingException - if the required padding mechanism (PKCS5Padding) is unavailable
    exception: NoSuchAlgorithmException - if the required cipher mode (CBC) is unavailable
    exception: NoSuchPaddingException - if the required padding mechanism (PKCS5Padding) is unavailable
Method from com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher Summary:
engineDoFinal,   engineDoFinal,   engineGetBlockSize,   engineGetIV,   engineGetKeySize,   engineGetOutputSize,   engineGetParameters,   engineInit,   engineInit,   engineInit,   engineSetMode,   engineSetPadding,   engineUnwrap,   engineUpdate,   engineUpdate,   engineWrap
Methods from javax.crypto.CipherSpi:
a,   engineDoFinal,   engineDoFinal,   engineDoFinal,   engineGetBlockSize,   engineGetIV,   engineGetKeySize,   engineGetOutputSize,   engineGetParameters,   engineInit,   engineInit,   engineInit,   engineSetMode,   engineSetPadding,   engineUnwrap,   engineUpdate,   engineUpdate,   engineUpdate,   engineWrap
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher Detail:
 protected byte[] engineDoFinal(byte[] input,
    int inputOffset,
    int inputLen) throws IllegalBlockSizeException, BadPaddingException 
    Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this cipher was initialized.

    The first inputLen bytes in the input buffer, starting at inputOffset, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in a new buffer.

    The cipher is reset to its initial state (uninitialized) after this call.

 protected int engineDoFinal(byte[] input,
    int inputOffset,
    int inputLen,
    byte[] output,
    int outputOffset) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException 
    Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this cipher was initialized.

    The first inputLen bytes in the input buffer, starting at inputOffset, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in the output buffer, starting at outputOffset.

    The cipher is reset to its initial state (uninitialized) after this call.

 protected int engineGetBlockSize() 
    Returns the block size (in bytes).
 protected byte[] engineGetIV() 
    Returns the initialization vector (IV) in a new buffer.

    This is useful in the case where a random IV has been created (see init), or in the context of password-based encryption or decryption, where the IV is derived from a user-supplied password.

 protected int engineGetKeySize(Key key) throws InvalidKeyException 
    Returns the key size of the given key object.
 protected int engineGetOutputSize(int inputLen) 
    Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes).

    This call takes into account any unprocessed (buffered) data from a previous update call, and padding.

    The actual output length of the next update or doFinal call may be smaller than the length returned by this method.

 protected AlgorithmParameters engineGetParameters() 
    Returns the parameters used with this cipher.

    The returned parameters may be the same that were used to initialize this cipher, or may contain the default set of parameters or a set of randomly generated parameters used by the underlying cipher implementation (provided that the underlying cipher implementation uses a default set of parameters or creates new parameters if it needs parameters but was not initialized with any).

 protected  void engineInit(int opmode,
    Key key,
    SecureRandom random) throws InvalidKeyException 
    Initializes this cipher with a key and a source of randomness. The cipher is initialized for one of the following four operations: encryption, decryption, key wrapping or key unwrapping, depending on the value of opmode.

    If this cipher (including its underlying feedback or padding scheme) requires any random bytes, it will get them from random.

 protected  void engineInit(int opmode,
    Key key,
    AlgorithmParameterSpec params,
    SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException 
    Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness. The cipher is initialized for encryption or decryption, depending on the value of opmode.

    If this cipher (including its underlying feedback or padding scheme) requires any random bytes, it will get them from random.

 protected  void engineInit(int opmode,
    Key key,
    AlgorithmParameters params,
    SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException 
 protected  void engineSetMode(String mode) throws NoSuchAlgorithmException 
    Sets the mode of this cipher. This algorithm can only be run in CBC mode.
 protected  void engineSetPadding(String paddingScheme) throws NoSuchPaddingException 
    Sets the padding mechanism of this cipher. This algorithm only uses PKCS #5 padding.
 protected Key engineUnwrap(byte[] wrappedKey,
    String wrappedKeyAlgorithm,
    int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException 
    Unwrap a previously wrapped key.
 protected byte[] engineUpdate(byte[] input,
    int inputOffset,
    int inputLen) 
    Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

    The first inputLen bytes in the input buffer, starting at inputOffset, are processed, and the result is stored in a new buffer.

 protected int engineUpdate(byte[] input,
    int inputOffset,
    int inputLen,
    byte[] output,
    int outputOffset) throws ShortBufferException 
    Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

    The first inputLen bytes in the input buffer, starting at inputOffset, are processed, and the result is stored in the output buffer, starting at outputOffset.

 protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyException 
    Wrap a key.