Class CipherWithWrappingSpi


  • public abstract class CipherWithWrappingSpi
    extends javax.crypto.CipherSpi
    This class extends the javax.crypto.CipherSpi class with a concrete implementation of the methods for wrapping and unwrapping keys.
    See Also:
    CipherSpi, DESCipher, PBEWithMD5AndDESCipher
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.security.Key engineUnwrap​(byte[] wrappedKey, java.lang.String wrappedKeyAlgorithm, int wrappedKeyType)
      Unwrap a previously wrapped key.
      protected byte[] engineWrap​(java.security.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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CipherWithWrappingSpi

        public CipherWithWrappingSpi()
        Constructor
    • Method Detail

      • engineWrap

        protected final byte[] engineWrap​(java.security.Key key)
                                   throws javax.crypto.IllegalBlockSizeException,
                                          java.security.InvalidKeyException
        Wrap a key.
        Overrides:
        engineWrap in class javax.crypto.CipherSpi
        Parameters:
        key - the key to be wrapped
        Returns:
        the wrapped key.
        Throws:
        javax.crypto.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.
        java.security.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 java.security.Key engineUnwrap​(byte[] wrappedKey,
                                                       java.lang.String wrappedKeyAlgorithm,
                                                       int wrappedKeyType)
                                                throws java.security.InvalidKeyException,
                                                       java.security.NoSuchAlgorithmException
        Unwrap a previously wrapped key.
        Overrides:
        engineUnwrap in class javax.crypto.CipherSpi
        Parameters:
        wrappedKey - the key to be unwrapped
        wrappedKeyAlgorithm - the algorithm of the wrapped key
        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:
        java.security.InvalidKeyException - if the wrappedKey does not represent a wrapped key, or if the algorithm associated with the wrapped key is different from wrappedKeyAlgorithm, or its key type is different from wrappedKeyType.
        java.security.NoSuchAlgorithmException - if no installed providers can create keys for the wrappedKeyAlgorithm.