Class NullCipherSpi

java.lang.Object
javax.crypto.CipherSpi
org.apache.harmony.crypto.internal.NullCipherSpi

public class NullCipherSpi
extends CipherSpi
CipherSpi implementation for javax.crypto.NullCipher
  • Constructor Summary

    Constructors
    Constructor Description
    NullCipherSpi()  
  • Method Summary

    Modifier and Type Method Description
    byte[] engineDoFinal​(byte[] input, int inputOffset, int inputLen)
    Finishes a multi-part transformation (encryption or decryption).
    int engineDoFinal​(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
    Finishes a multi-part transformation (encryption or decryption).
    int engineDoFinal​(ByteBuffer input, ByteBuffer output)
    Finishes a multi-part transformation (encryption or decryption).
    int engineGetBlockSize()
    Returns the block size of this cipher (in bytes)
    byte[] engineGetIV()
    Returns the Initialization Vector (IV) that was used to initialize this cipher or null if none was used.
    int engineGetKeySize​(Key key)
    Returns the size of a specified key object in bits.
    int engineGetOutputSize​(int inputLen)
    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.
    AlgorithmParameters engineGetParameters()
    Returns the parameters that where used to create this cipher instance.
    void engineInit​(int opmode, Key key, AlgorithmParameters params, SecureRandom random)
    Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.
    void engineInit​(int opmode, Key key, SecureRandom random)
    Initializes this cipher instance with the specified key and a source of randomness.
    void engineInit​(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)
    Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.
    void engineSetMode​(String arg0)
    Sets the mode for this cipher.
    void engineSetPadding​(String arg0)
    Sets the padding method for this cipher.
    Key engineUnwrap​(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)
    Unwraps a key using this cipher instance.
    byte[] engineUpdate​(byte[] input, int inputOffset, int inputLen)
    Continues a multi-part transformation (encryption or decryption).
    int engineUpdate​(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
    Continues a multi-part transformation (encryption or decryption).
    int engineUpdate​(ByteBuffer input, ByteBuffer output)
    Continues a multi-part transformation (encryption or decryption).
    byte[] engineWrap​(Key key)
    Wraps a key using this cipher instance.

    Methods inherited from class javax.crypto.CipherSpi

    engineUpdateAAD, engineUpdateAAD

    Methods inherited from class java.lang.Object

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

    • NullCipherSpi

      public NullCipherSpi()
  • Method Details

    • engineSetMode

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

      public void engineSetPadding​(String arg0) throws NoSuchPaddingException
      Description copied from class: CipherSpi
      Sets the padding method for this cipher.
      Specified by:
      engineSetPadding in class CipherSpi
      Parameters:
      arg0 - the name of the padding method.
      Throws:
      NoSuchPaddingException - if the specified padding method is not supported by this cipher.
    • engineGetBlockSize

      public 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.
    • engineGetOutputSize

      public 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).
    • engineGetIV

      public 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.
    • engineGetParameters

      public 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.
    • engineInit

      public void engineInit​(int opmode, Key key, SecureRandom random) throws InvalidKeyException
      Description copied from class: CipherSpi
      Initializes this cipher instance with the specified key and a source of randomness.

      The cipher will be initialized for the specified operation (one of: encryption, decryption, key wrapping or key unwrapping) depending on opmode.

      If this cipher instance needs any algorithm parameters or random values that the specified key cannot provide, the underlying implementation of this cipher is supposed to generate the required parameters (using its provider or random values). Random values will be generated using random;

      When a cipher instance is initialized by a call to any of the init methods, the state of the instance is overridden, means it is equivalent to creating a new instance and calling it init method.

      Specified by:
      engineInit in class CipherSpi
      Parameters:
      opmode - the operation this cipher instance should be initialized for (one of: ENCRYPT_MODE, DECRYPT_MODE, WRAP_MODE or UNWRAP_MODE).
      key - the input key for the operation.
      random - the source of randomness to use.
      Throws:
      InvalidKeyException - if the specified key cannot be used to initialize this cipher instance.
    • engineInit

      public void engineInit​(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
      Description copied from class: CipherSpi
      Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.

      The cipher will be initialized for the specified operation (one of: encryption, decryption, key wrapping or key unwrapping) depending on opmode.

      If this cipher instance needs any algorithm parameters and params is null, the underlying implementation of this cipher is supposed to generate the required parameters (using its provider or random values). Random values are generated using random.

      When a cipher instance is initialized by a call to any of the init methods, the state of the instance is overridden, means it is equivalent to creating a new instance and calling it init method.

      Specified by:
      engineInit in class CipherSpi
      Parameters:
      opmode - the operation this cipher instance should be initialized for (one of: ENCRYPT_MODE, DECRYPT_MODE, WRAP_MODE or UNWRAP_MODE).
      key - the input key for the operation.
      params - the algorithm parameters.
      random - the source of randomness to use.
      Throws:
      InvalidKeyException - if the specified key cannot be used to initialize this cipher instance.
      InvalidAlgorithmParameterException - it the specified parameters are inappropriate for this cipher.
    • engineInit

      public void engineInit​(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
      Description copied from class: CipherSpi
      Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.

      The cipher will be initialized for the specified operation (one of: encryption, decryption, key wrapping or key unwrapping) depending on opmode.

      If this cipher instance needs any algorithm parameters and params is null, the underlying implementation of this cipher is supposed to generate the required parameters (using its provider or random values). Random values are generated using random.

      When a cipher instance is initialized by a call to any of the init methods, the state of the instance is overridden, means it is equivalent to creating a new instance and calling it init method.

      Specified by:
      engineInit in class CipherSpi
      Parameters:
      opmode - the operation this cipher instance should be initialized for (one of: ENCRYPT_MODE, DECRYPT_MODE, WRAP_MODE or UNWRAP_MODE).
      key - the input key for the operation.
      params - the algorithm parameters.
      random - the source of randomness to use.
      Throws:
      InvalidKeyException - if the specified key cannot be used to initialize this cipher instance.
      InvalidAlgorithmParameterException - if the specified parameters are inappropriate for this cipher.
    • engineUpdate

      public byte[] engineUpdate​(byte[] input, int inputOffset, int inputLen)
      Description copied from class: CipherSpi
      Continues a multi-part transformation (encryption or decryption). The transformed bytes are returned.
      Specified by:
      engineUpdate in class CipherSpi
      Parameters:
      input - the input bytes to transform.
      inputOffset - the offset in the input to start.
      inputLen - the length of the input to transform.
      Returns:
      the transformed bytes in a new buffer, or null if the input has zero length.
    • engineUpdate

      public int engineUpdate​(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException
      Description copied from class: CipherSpi
      Continues a multi-part transformation (encryption or decryption). The transformed bytes are stored in the output buffer.

      If the size of the output buffer is too small to hold the result, a ShortBufferException is thrown. Use getOutputSize to check for the size of the output buffer.

      Specified by:
      engineUpdate in class CipherSpi
      Parameters:
      input - the input bytes to transform.
      inputOffset - the offset in the input to start.
      inputLen - the length of the input to transform.
      output - the output buffer.
      outputOffset - the offset in the output buffer.
      Returns:
      the number of bytes placed in output.
      Throws:
      ShortBufferException - if the size of the output buffer is too small.
    • engineUpdate

      public int engineUpdate​(ByteBuffer input, ByteBuffer output) throws ShortBufferException
      Description copied from class: CipherSpi
      Continues a multi-part transformation (encryption or decryption). The input.remaining() bytes starting at input.position() are transformed and stored in the output buffer.

      If the output.remaining() is too small to hold the transformed bytes a ShortBufferException is thrown. Use getOutputSize to check for the size of the output buffer.

      Overrides:
      engineUpdate in class CipherSpi
      Parameters:
      input - the input buffer to transform.
      output - the output buffer to store the result within.
      Returns:
      the number of bytes stored in the output buffer.
      Throws:
      ShortBufferException - if the size of the output buffer is too small.
    • engineDoFinal

      public byte[] engineDoFinal​(byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException
      Description copied from class: CipherSpi
      Finishes a multi-part transformation (encryption or decryption).

      Processes the inputLen bytes in input buffer at inputOffset, and any bytes that have been buffered in previous update calls.

      Specified by:
      engineDoFinal in class CipherSpi
      Parameters:
      input - the input buffer.
      inputOffset - the offset in the input buffer.
      inputLen - the length of the input.
      Returns:
      the final bytes from the transformation.
      Throws:
      IllegalBlockSizeException - if the size of the resulting bytes is not a multiple of the cipher block size.
      BadPaddingException - if the padding of the data does not match the padding scheme.
    • engineDoFinal

      public int engineDoFinal​(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
      Description copied from class: CipherSpi
      Finishes a multi-part transformation (encryption or decryption).

      Processes the inputLen bytes in input buffer at inputOffset, and any bytes that have been buffered in previous update calls.

      Specified by:
      engineDoFinal in class CipherSpi
      Parameters:
      input - the input buffer.
      inputOffset - the offset in the input buffer.
      inputLen - the length of the input.
      output - the output buffer for the transformed bytes.
      outputOffset - the offset in the output buffer.
      Returns:
      the number of bytes placed in the output buffer.
      Throws:
      ShortBufferException - if the size of the output buffer is too small.
      IllegalBlockSizeException - if the size of the resulting bytes is not a multiple of the cipher block size.
      BadPaddingException - if the padding of the data does not match the padding scheme.
    • engineDoFinal

      public int engineDoFinal​(ByteBuffer input, ByteBuffer output) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
      Description copied from class: CipherSpi
      Finishes a multi-part transformation (encryption or decryption).

      Processes the input.remaining() bytes in input buffer at input.position(), and any bytes that have been buffered in previous update calls. The transformed bytes are placed into output buffer.

      Overrides:
      engineDoFinal in class CipherSpi
      Parameters:
      input - the input buffer.
      output - the output buffer.
      Returns:
      the number of bytes placed into the output buffer.
      Throws:
      ShortBufferException - if the size of the output buffer is too small.
      IllegalBlockSizeException - if the size of the resulting bytes is not a multiple of the cipher block size.
      BadPaddingException - if the padding of the data does not match the padding scheme.
    • engineWrap

      public 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

      public Key engineUnwrap​(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException
      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.
      NoSuchAlgorithmException - if no provider can be found that can create a key of type wrappedKeyType for the wrappedKeyAlgorithm.
    • engineGetKeySize

      public int engineGetKeySize​(Key key) throws InvalidKeyException
      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.
      Throws:
      InvalidKeyException - if the size of the key cannot be determined by this implementation.