Class BaseCipherSpi

  • Direct Known Subclasses:
    CipherSpi

    public abstract class BaseCipherSpi
    extends CipherSpi
    • Constructor Detail

      • BaseCipherSpi

        protected BaseCipherSpi()
    • Method Detail

      • engineGetBlockSize

        protected int engineGetBlockSize()
        Description copied from class: CipherSpi
        Returns the block size of this cipher (in bytes)
        Specified by:
        engineGetBlockSize in class CipherSpi
        Returns:
        the block size of this cipher, or zero if this cipher is not a block cipher.
      • engineGetIV

        protected byte[] engineGetIV()
        Description copied from class: CipherSpi
        Returns the Initialization Vector (IV) that was used to initialize this cipher or null if none was used.
        Specified by:
        engineGetIV in class CipherSpi
        Returns:
        the Initialization Vector (IV), or null if none was used.
      • engineGetKeySize

        protected int engineGetKeySize​(Key key)
        Description copied from class: CipherSpi
        Returns the size of a specified key object in bits. This method has been added to this class (for backwards compatibility, it cannot be abstract). If this method is not overridden, it throws an UnsupportedOperationException.
        Overrides:
        engineGetKeySize in class CipherSpi
        Parameters:
        key - the key to get the size for.
        Returns:
        the size of a specified key object in bits.
      • engineGetOutputSize

        protected int engineGetOutputSize​(int inputLen)
        Description copied from class: CipherSpi
        Returns the size for a buffer (in bytes), that the next call to update of doFinal would return, taking into account any buffered data from previous update calls and padding.

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

        Specified by:
        engineGetOutputSize in class CipherSpi
        Parameters:
        inputLen - the length of the input (in bytes).
        Returns:
        the size for a buffer (in bytes).
      • engineGetParameters

        protected AlgorithmParameters engineGetParameters()
        Description copied from class: CipherSpi
        Returns the parameters that where used to create this cipher instance.

        These may be a the same parameters that were used to create this cipher instance, or may be a combination of default and random parameters, depending on the underlying cipher implementation.

        Specified by:
        engineGetParameters in class CipherSpi
        Returns:
        the parameters that where used to create this cipher instance, or null if this cipher instance does not have any parameters at all.
      • engineWrap

        protected byte[] engineWrap​(Key key)
                             throws IllegalBlockSizeException,
                                    InvalidKeyException
        Description copied from class: CipherSpi
        Wraps a key using this cipher instance. This method has been added to this class (for backwards compatibility, it cannot be abstract). If this method is not overridden, it throws an UnsupportedOperationException.
        Overrides:
        engineWrap in class CipherSpi
        Parameters:
        key - the key to wrap.
        Returns:
        the wrapped key
        Throws:
        IllegalBlockSizeException - if the size of the resulting bytes is not a multiple of the cipher block size.
        InvalidKeyException - if this cipher instance cannot wrap this key.
      • engineUnwrap

        protected Key engineUnwrap​(byte[] wrappedKey,
                                   String wrappedKeyAlgorithm,
                                   int wrappedKeyType)
                            throws InvalidKeyException
        Description copied from class: CipherSpi
        Unwraps a key using this cipher instance.

        This method has been added to this class (for backwards compatibility, it cannot be abstract). If this method is not overridden, it throws an UnsupportedOperationException.

        Overrides:
        engineUnwrap in class CipherSpi
        Parameters:
        wrappedKey - the wrapped key to unwrap.
        wrappedKeyAlgorithm - the algorithm for the wrapped key.
        wrappedKeyType - the type of the wrapped key (one of: SECRET_KEY, PRIVATE_KEY or PUBLIC_KEY)
        Returns:
        the unwrapped key.
        Throws:
        InvalidKeyException - if the wrappedKey cannot be unwrapped to a key of type wrappedKeyType for the wrappedKeyAlgorithm.