public final class

DESedeWrapCipher

extends CipherSpi
java.lang.Object
   ↳ javax.crypto.CipherSpi
     ↳ com.sun.crypto.provider.DESedeWrapCipher

Summary

Public Constructors
DESedeWrapCipher()
Creates an instance of CMS DESede KeyWrap cipher with default mode, i.e.
Protected Methods
byte[] engineDoFinal(byte[] in, int inOffset, int inLen)
This operation is not supported by this cipher.
int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
This operation is not supported by this cipher.
int engineGetBlockSize()
Returns the block size (in bytes), i.e.
byte[] engineGetIV()
Returns the initialization vector (IV) in a new buffer.
int engineGetKeySize(Key key)
Returns the key size of the given key object in number of bits.
int engineGetOutputSize(int inputLen)
Returns the length in bytes that an output buffer would need to be given the input length inputLen (in bytes).
AlgorithmParameters engineGetParameters()
Returns the parameters used with this cipher.
void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random)
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness.
void engineInit(int opmode, Key key, SecureRandom random)
Initializes this cipher with a key and a source of randomness.
void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness.
void engineSetMode(String mode)
Sets the mode of this cipher.
void engineSetPadding(String padding)
Sets the padding mechanism of this cipher.
Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)
Unwrap a previously wrapped key.
int engineUpdate(byte[] in, int inOffset, int inLen, byte[] out, int outOffset)
This operation is not supported by this cipher.
byte[] engineUpdate(byte[] in, int inOffset, int inLen)
This operation is not supported by this cipher.
byte[] engineWrap(Key key)
Wrap a key.
[Expand]
Inherited Methods
From class javax.crypto.CipherSpi
From class java.lang.Object

Public Constructors

public DESedeWrapCipher ()

Creates an instance of CMS DESede KeyWrap cipher with default mode, i.e. "CBC" and padding scheme, i.e. "NoPadding".

Throws
SecurityException if this constructor fails to verify its own integrity.

Protected Methods

protected byte[] engineDoFinal (byte[] in, int inOffset, int inLen)

This operation is not supported by this cipher. Since it's impossible to initialize this cipher given the current Cipher.engineInit(...) implementation, IllegalStateException will always be thrown upon invocation.

Parameters
in the input buffer.
inOffset the offset in in where the input starts.
inLen the input length.
Returns
  • the new buffer with the result.

protected int engineDoFinal (byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)

This operation is not supported by this cipher. Since it's impossible to initialize this cipher given the current Cipher.engineInit(...) implementation, IllegalStateException will always be thrown upon invocation.

Parameters
input the input buffer
inputOffset the offset in input where the input starts
inputLen the input length
output the buffer for the result
outputOffset the offset in output where the result is stored
Returns
  • the number of bytes stored in out.

protected int engineGetBlockSize ()

Returns the block size (in bytes), i.e. 8 bytes.

Returns
  • the block size (in bytes), i.e. 8 bytes.

protected byte[] engineGetIV ()

Returns the initialization vector (IV) in a new buffer.

Returns
  • the initialization vector, or null if the underlying algorithm does not use an IV, or if the IV has not yet been set.

protected int engineGetKeySize (Key key)

Returns the key size of the given key object in number of bits. This cipher always return the same key size as the DESede ciphers.

Parameters
key the key object.
Returns
  • the "effective" key size of the given key object.
Throws
InvalidKeyException if key is invalid.

protected int engineGetOutputSize (int inputLen)

Returns the length in bytes that an output buffer would need to be given the input length inputLen (in bytes).

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

Parameters
inputLen the input length (in bytes).
Returns
  • the required output buffer size (in bytes).

protected AlgorithmParameters engineGetParameters ()

Returns the parameters used with this cipher. Note that null maybe returned if this cipher does not use any parameters or when it has not be set, e.g. initialized with UNWRAP_MODE but wrapped key data has not been given.

Returns
  • the parameters used with this cipher; can be null.

protected void engineInit (int opmode, Key key, AlgorithmParameters params, SecureRandom random)

Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness.

The cipher only supports the following two operation modes: Cipher.WRAP_MODE, and Cipher.UNWRAP_MODE.

For modes other than the above two, UnsupportedOperationException will be thrown.

If this cipher requires an initialization vector (IV), it will get it from random.

Parameters
opmode the operation mode of this cipher. Only WRAP_MODE or UNWRAP_MODE) are accepted.
key the secret key.
params the algorithm parameters.
random the source of randomness.
Throws
InvalidKeyException if the given key is inappropriate.
InvalidAlgorithmParameterException if the given algorithm parameters are inappropriate for this cipher.

protected void engineInit (int opmode, Key key, SecureRandom random)

Initializes this cipher with a key and a source of randomness.

The cipher only supports the following two operation modes: Cipher.WRAP_MODE, and Cipher.UNWRAP_MODE.

For modes other than the above two, UnsupportedOperationException will be thrown.

If this cipher requires an initialization vector (IV), it will get it from random.

Parameters
opmode the operation mode of this cipher. Only WRAP_MODE or UNWRAP_MODE) are accepted.
key the secret key.
random the source of randomness.
Throws
InvalidKeyException if the given key is inappropriate or if parameters are required but not supplied.

protected void engineInit (int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)

Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness.

The cipher only supports the following two operation modes: Cipher.WRAP_MODE, and Cipher.UNWRAP_MODE.

For modes other than the above two, UnsupportedOperationException will be thrown.

If this cipher requires an initialization vector (IV), it will get it from random.

Parameters
opmode the operation mode of this cipher. Only WRAP_MODE or UNWRAP_MODE) are accepted.
key the secret key.
params the algorithm parameters.
random the source of randomness.
Throws
InvalidKeyException if the given key is inappropriate.
InvalidAlgorithmParameterException if the given algorithm parameters are inappropriate for this cipher.

protected void engineSetMode (String mode)

Sets the mode of this cipher. Only "CBC" mode is accepted for this cipher.

Parameters
mode the cipher mode.
Throws
NoSuchAlgorithmException if the requested cipher mode is not "CBC".

protected void engineSetPadding (String padding)

Sets the padding mechanism of this cipher. Only "NoPadding" schmem is accepted for this cipher.

Parameters
padding the padding mechanism.
Throws
NoSuchPaddingException if the requested padding mechanism is not "NoPadding".

protected Key engineUnwrap (byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)

Unwrap a previously wrapped key.

Parameters
wrappedKey the key to be unwrapped.
wrappedKeyAlgorithm the algorithm the wrapped key is for.
wrappedKeyType the type of the wrapped key. This is one of Cipher.SECRET_KEY, Cipher.PRIVATE_KEY, or Cipher.PUBLIC_KEY.
Returns
  • the unwrapped key.
Throws
NoSuchAlgorithmException if no installed providers can create keys of type wrappedKeyType for the wrappedKeyAlgorithm.
InvalidKeyException if wrappedKey does not represent a wrapped key of type wrappedKeyType for the wrappedKeyAlgorithm.

protected int engineUpdate (byte[] in, int inOffset, int inLen, byte[] out, int outOffset)

This operation is not supported by this cipher. Since it's impossible to initialize this cipher given the current Cipher.engineInit(...) implementation, IllegalStateException will always be thrown upon invocation.

Parameters
in the input buffer.
inOffset the offset in in where the input starts.
inLen the input length.
out the buffer for the result.
outOffset the offset in out where the result is stored.
Returns
  • n/a.
Throws
IllegalStateException upon invocation of this method.
ShortBufferException

protected byte[] engineUpdate (byte[] in, int inOffset, int inLen)

This operation is not supported by this cipher. Since it's impossible to initialize this cipher given the current Cipher.engineInit(...) implementation, IllegalStateException will always be thrown upon invocation.

Parameters
in the input buffer.
inOffset the offset in in where the input starts.
inLen the input length.
Returns
  • n/a.
Throws
IllegalStateException upon invocation of this method.

protected byte[] engineWrap (Key key)

Wrap a key.

Parameters
key the key to be wrapped.
Returns
  • the wrapped key.
Throws
IllegalBlockSizeException if this cipher is a block cipher, no padding has been requested, and the length of the encoding of the key to be wrapped is not a multiple of the block size.
InvalidKeyException if it is impossible or unsafe to wrap the key with this cipher (e.g., a hardware protected key is being passed to a software only cipher).