public abstract class

CipherWithWrappingSpi

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

Class Overview

This class entends the javax.crypto.CipherSpi class with a concrete implementation of the methods for wrapping and unwrapping keys.

Summary

Public Constructors
CipherWithWrappingSpi()
Protected Methods
final Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)
Unwrap a previously wrapped key.
final byte[] engineWrap(Key key)
Wrap a key.
[Expand]
Inherited Methods
From class javax.crypto.CipherSpi
From class java.lang.Object

Public Constructors

public CipherWithWrappingSpi ()

Protected Methods

protected final 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
InvalidKeyException if wrappedKey does not represent a wrapped key, or if the algorithm associated with the wrapped key is different from wrappedKeyAlgorithm and/or its key type is different from wrappedKeyType.
NoSuchAlgorithmException if no installed providers can create keys for the wrappedKeyAlgorithm.

protected final 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).