java.lang.Object
javax.crypto.CipherSpi
org.bouncycastle.jcajce.provider.asymmetric.util.BaseCipherSpi
Direct Known Subclasses:
CipherSpi

public abstract class BaseCipherSpi
extends CipherSpi
  • Field Details

  • Constructor Details

    • BaseCipherSpi

      protected BaseCipherSpi()
  • Method Details

    • 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.
    • engineSetMode

      protected void engineSetMode​(String mode) throws NoSuchAlgorithmException
      Description copied from class: CipherSpi
      Sets the mode for this cipher.
      Specified by:
      engineSetMode in class CipherSpi
      Parameters:
      mode - the name of the cipher mode.
      Throws:
      NoSuchAlgorithmException - if the specified cipher mode is not supported by this provider.
    • engineSetPadding

      protected void engineSetPadding​(String padding) throws NoSuchPaddingException
      Description copied from class: CipherSpi
      Sets the padding method for this cipher.
      Specified by:
      engineSetPadding in class CipherSpi
      Parameters:
      padding - the name of the padding method.
      Throws:
      NoSuchPaddingException - if the specified padding method is not supported by this cipher.
    • 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.