-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]engineDoFinal(byte[] input, int inputOffset, int inputLen) Encrypting or decrypting data in a single-part operation, or finishing a multiple-part operation is not supported.protected intengineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) Encrypting or decrypting data in a single-part operation, or finishing a multiple-part operation is not supported.protected intReturns cipher block size in bytes.protected byte[]Returns the initialization vector (IV) used with this cipher.protected intengineGetKeySize(Key key) Returns the key size of the given key object.protected intengineGetOutputSize(int inputLen) Returns the length in bytes that an output buffer would need.protected AlgorithmParametersReturns the parameters used with this cipher.protected voidengineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) protected voidengineInit(int opmode, Key key, SecureRandom random) Initializes this cipher with a key and a source of randomness.protected voidengineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) Initializes this cipher with a key and a source of randomness.protected voidengineSetMode(String mode) Setting the cipher mode is not supported.protected voidengineSetPadding(String paddingScheme) Setting the cipher padding mechanism is not supported.protected KeyengineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) Unwrap a previously wrapped CCA hardware DES, DESede, or AES key.protected byte[]engineUpdate(byte[] input, int inputOffset, int inputLen) Continuing a multiple-part encryption or decryption operation is not supported.protected intengineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) Continuing a multiple-part encryption or decryption operation is not supported.protected byte[]engineWrap(Key key) Wrap a CCA hardware DES, DESede, or AES key.Methods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineUpdate, engineUpdateAAD, engineUpdateAAD
-
Constructor Details
-
AESKeyWrap
public AESKeyWrap()Creates an instance of hardware AES key wrap.- Throws:
SecurityException- if this constructor fails to authenticate the JCE framework.
-
-
Method Details
-
engineGetBlockSize
protected int engineGetBlockSize()Returns cipher block size in bytes.- Specified by:
engineGetBlockSizein classCipherSpi- Returns:
- cipher block size in bytes.
-
engineGetOutputSize
protected int engineGetOutputSize(int inputLen) Returns the length in bytes that an output buffer would need.- Specified by:
engineGetOutputSizein classCipherSpi- Parameters:
inputLen- the input length in bytes, which will be ignored- Returns:
- the required output buffer size in bytes.
-
engineGetKeySize
Returns the key size of the given key object. This method is called by the JCE framework to ensure that the size of the key to be used does not exceed the maximum allowable key size specified in the Java restricted policy files.Since cryptographic operations using AES ciphers are always done at the cryptographic hardware level, and the hardware itself enforces the US export restrictions relating to cryptographic keys, we should always return a key size that will pass the restricted policy files check done by the JCE framework.
- Overrides:
engineGetKeySizein classCipherSpi- Parameters:
key- the key object- Returns:
- a key size that will pass the restricted policy files check done by the JCE framework.
-
engineInit
Initializes this cipher with a key and a source of randomness. This cipher may be initialized for key wrapping or key unwrapping operations only, depending on the value ofopmode. Encryption and decryption operations are not supported by this cipher.This cipher does not require an initialization vector (IV), so the source of randomness provided by
randommust be null. This method resets any existing state information.By default, keys are unwrapped as
SymmetricKeyConstants.KeyType.CKDSkeys.- Specified by:
engineInitin classCipherSpi- Parameters:
opmode- the operation mode of this cipher. This is one ofWRAP_MODEorUNWRAP_MODE. Please note thatENCRYPT_MODEandDECRYPT_MODEoperation modes are not supportedkey- the CCA hardware AES key encrypting keyrandom- the source of randomness, which must be null- Throws:
UnsupportedOperationException- if theopmodeis eitherENCRYPT_MODEorDECRYPT_MODE, which is not supported by this cipher.InvalidParameterException- if theopmodeis not a valid cipher operation mode or if a source of randomness is specified.NullPointerException- if the key is null.InvalidKeyException- if the given key not a CCA hardware AES key.
-
engineInit
protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException Initializes this cipher with a key and a source of randomness. This cipher may be initialized for key wrapping or key unwrapping operations only, depending on the value ofopmode. Encryption and decryption operations are not supported by this cipher.This cipher does not require an initialization vector (IV), so the source of randomness provided by
randommust be null. This method resets any existing state information.By default, keys are unwrapped as
SymmetricKeyConstants.KeyType.CKDSkeys.- Specified by:
engineInitin classCipherSpi- Parameters:
opmode- the operation mode of this cipher. This is one ofWRAP_MODEorUNWRAP_MODE. Please note thatENCRYPT_MODEandDECRYPT_MODEoperation modes are not supportedkey- the CCA hardware AES key encrypting keyparams- algorithm parameters that specify whether to unwrap keys asSymmetricKeyConstants.KeyType.SECURE_INTERNAL_TOKENkeys or asSymmetricKeyConstants.KeyType.CKDSkeys. Unwrapping toSymmetricKeyConstants.KeyType.CLEARkeys is not supported. This algorithm parameters is only supported inUNWRAP_MODErandom- the source of randomness, which must be null- Throws:
UnsupportedOperationException- if theopmodeis eitherENCRYPT_MODEorDECRYPT_MODE, which is not supported by this cipher.InvalidParameterException- if theopmodeis not a valid cipher operation mode or if a source of randomness is specified.NullPointerException- if the key is null.InvalidKeyException- if the given key not a CCA hardware AES key.InvalidAlgorithmParameterException- ifparamsis not null andopmodeisWRAP_MODE, or ifparamsis not an instance ofCCAAlgorithmParameterSpec, or if the algorithm parameters specify to unwrap keys asCLEARkeys.
-
engineInit
protected void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
engineInitin classCipherSpi- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException- See Also:
-
engineWrap
Wrap a CCA hardware DES, DESede, or AES key. The wrapped key will be formatted as a CCA external key token. ICSF HCR77A1 or above is required in order to wrap hardware DES or DESede keys using AES key encrypting keys.- Overrides:
engineWrapin classCipherSpi- Parameters:
key- the CCA hardware DES, DESede, or AES key to be wrapped- Returns:
- the wrapped key formatted as a CCA external key token.
- Throws:
NullPointerException- ifkeyis null.InvalidKeyException- if the provided key is not a CCA hardware DES, DESede, or AES key. Or if the key to be wrapped is a DES or Triple-DES key and ICSF version is less than HCR77A1.IllegalStateException- if this cipher is not initialized for theWRAP_MODEoperational mode.
-
engineUnwrap
protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException Unwrap a previously wrapped CCA hardware DES, DESede, or AES key. By default, all unwrapped keys will be CKDS keys stored in the CKDS, unless otherwise specified through algorithm parameter specs during cipher initialization.- Overrides:
engineUnwrapin classCipherSpi- Parameters:
wrappedKey- the previously wrapped CCA hardware DES, DESede, or AES key to be unwrappedwrappedKeyAlgorithm- the key algorithm of the original keywrappedKeyType- the type of wrapped key, this value must beCipher.SECRET_KEY- Returns:
- the unwrapped CCA hardware DES, DESede, or AES key.
- Throws:
NullPointerException- ifwrappedKeyis null.InvalidKeyException- ifwrappedKeyAlgorithmis not"DES","DESede","TripleDES","3DES", or"AES". Or ifwrappedKeyTypeis notCipher.SECRET_KEY, or there is an issue creating the unwrapped CCA hardware key. Or if the key to be unwrapped is a DES or Triple-DES key and ICSF version is less than HCR77A1.IllegalStateException- if this cipher is not initialized for theUNWRAP_MODEoperational mode.
-
engineSetMode
Setting the cipher mode is not supported.- Specified by:
engineSetModein classCipherSpi- Parameters:
mode- the cipher mode- Throws:
UnsupportedOperationException- always.
-
engineSetPadding
Setting the cipher padding mechanism is not supported.- Specified by:
engineSetPaddingin classCipherSpi- Parameters:
paddingScheme- the padding mechanism- Throws:
UnsupportedOperationException- always.
-
engineGetIV
protected byte[] engineGetIV()Returns the initialization vector (IV) used with this cipher.- Specified by:
engineGetIVin classCipherSpi- Returns:
- null, because this cipher does not use any IV.
-
engineGetParameters
Returns the parameters used with this cipher.- Specified by:
engineGetParametersin classCipherSpi- Returns:
- null, because this cipher does not return any parameters.
-
engineUpdate
protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) Continuing a multiple-part encryption or decryption operation is not supported.- Specified by:
engineUpdatein classCipherSpi- Throws:
UnsupportedOperationException- always.
-
engineUpdate
protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) Continuing a multiple-part encryption or decryption operation is not supported.- Specified by:
engineUpdatein classCipherSpi- Throws:
UnsupportedOperationException- always.
-
engineDoFinal
protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) Encrypting or decrypting data in a single-part operation, or finishing a multiple-part operation is not supported.- Specified by:
engineDoFinalin classCipherSpi- Throws:
UnsupportedOperationException- always.
-
engineDoFinal
protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) Encrypting or decrypting data in a single-part operation, or finishing a multiple-part operation is not supported.- Specified by:
engineDoFinalin classCipherSpi- Throws:
UnsupportedOperationException- always.
-