java.lang.Object
javax.crypto.CipherSpi
com.ibm.crypto.hdwrCCA.provider.CipherWithWrappingSpi
This class extends the
javax.crypto.CipherSpi
class with a concrete implementation of the methods for wrapping and
unwrapping keys.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final Key
engineUnwrap
(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) Unwrap a previously wrapped key.protected final byte[]
engineWrap
(Key key) Wrap a key.Methods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate, engineUpdate, engineUpdateAAD, engineUpdateAAD
-
Constructor Details
-
CipherWithWrappingSpi
public CipherWithWrappingSpi()Constructor
-
-
Method Details
-
engineWrap
Wrap a key.- Overrides:
engineWrap
in classCipherSpi
- 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).
-
engineUnwrap
protected final Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException Unwrap a previously wrapped key.- Overrides:
engineUnwrap
in classCipherSpi
- Parameters:
wrappedKey
- the key to be unwrappedwrappedKeyAlgorithm
- the algorithm of the wrapped keywrappedKeyType
- the type of the wrapped key. This is one ofCipher.SECRET_KEY
,Cipher.PRIVATE_KEY
, orCipher.PUBLIC_KEY
.- Returns:
- the unwrapped key.
- Throws:
InvalidKeyException
- if thewrappedKey
does not represent a wrapped key, or if the algorithm associated with the wrapped key is different fromwrappedKeyAlgorithm
, or its key type is different fromwrappedKeyType
.NoSuchAlgorithmException
- if no installed providers can create keys for thewrappedKeyAlgorithm
.
-