Interface Cipher

All Known Subinterfaces:
AsymmetricCipher, SymmetricCipher

public interface Cipher
Interface on a Block cipher engines ready to process data for encryption and decryption.
Since:
5.4M1
Version:
$Id: 84ec9ab2bd6f01c857350a7ca4864deeb6c8d09a $
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Finishes a multiple-part encryption or decryption operation.
    byte[]
    doFinal(byte[] input)
    Encrypts or decrypts data in a one shot operation, or finishes a multiple-part operation.
    byte[]
    doFinal(byte[] input, int inputOffset, int inputLen)
    Encrypts or decrypts data in a one shot operation, or finishes a multiple-part operation.
     
    int
     
    Return a filtered input stream based on this cipher.
    int
     
    Return a filtered output stream based on this cipher.
    boolean
     
    byte[]
    update(byte[] input)
    Continues a multiple-part encryption or decryption operation, processing another data chunk.
    byte[]
    update(byte[] input, int inputOffset, int inputLen)
    Continues a multiple-part encryption or decryption operation processing another data chunk.
  • Method Details

    • getAlgorithmName

      String getAlgorithmName()
      Returns:
      the algorithm name of the underlying cipher. The returned string has in the form algorithm/mode/padding, like in "DES/CBC/PKCS5Padding".
    • getInputBlockSize

      int getInputBlockSize()
      Returns:
      the size of input data process as a block by this cipher (in bytes).
    • getOutputBlockSize

      int getOutputBlockSize()
      Returns:
      the size of encrypted data returned for a block of input data (in bytes).
    • isForEncryption

      boolean isForEncryption()
      Returns:
      true if the cipher is initialised for encryption, and false for decryption.
    • getInputStream

      FilterInputStream getInputStream(InputStream is)
      Return a filtered input stream based on this cipher. The cipher is reset each time this function is called. Any previously retrieved input stream or in progress operation get discarded.
      Parameters:
      is - an input stream to filter.
      Returns:
      a filtered input stream based on this cipher.
    • getOutputStream

      FilterOutputStream getOutputStream(OutputStream os)
      Return a filtered output stream based on this cipher. The cipher is reset each time this function is called. Any previously retrieved input stream or in progress operation get discarded.
      Parameters:
      os - an output stream to filter.
      Returns:
      a filtered output stream based on this cipher.
    • update

      byte[] update(byte[] input)
      Continues a multiple-part encryption or decryption operation, processing another data chunk.
      Parameters:
      input - the input buffer.
      Returns:
      the new buffer with the result, or null if the underlying cipher is a block cipher and the input data is too short to result in a new block.
    • update

      byte[] update(byte[] input, int inputOffset, int inputLen)
      Continues a multiple-part encryption or decryption operation processing another data chunk.
      Parameters:
      input - the input buffer.
      inputOffset - the offset in input where the input starts.
      inputLen - the input length.
      Returns:
      the new buffer with the result, or null if the underlying cipher is a block cipher and the input data is too short to result in a new block.
    • doFinal

      byte[] doFinal() throws GeneralSecurityException
      Finishes a multiple-part encryption or decryption operation. Input data that may have been buffered during a previous update operation is processed, with padding being applied. The result is stored in a new buffer. Upon finish, this method resets this cipher.
      Returns:
      the new buffer with the result.
      Throws:
      GeneralSecurityException - if this encryption algorithm is unable to proceed properly.
    • doFinal

      byte[] doFinal(byte[] input) throws GeneralSecurityException
      Encrypts or decrypts data in a one shot operation, or finishes a multiple-part operation. The bytes in the input buffer, and any input bytes that may have been buffered during a previous update operation, are processed, with padding being applied. The result is stored in a new buffer. Upon finish, this method resets this cipher.
      Parameters:
      input - the input buffer.
      Returns:
      the new buffer with the result.
      Throws:
      GeneralSecurityException - if this encryption algorithm is unable to proceed properly.
    • doFinal

      byte[] doFinal(byte[] input, int inputOffset, int inputLen) throws GeneralSecurityException
      Encrypts or decrypts data in a one shot operation, or finishes a multiple-part operation. The first inputLen bytes in the input buffer, starting at inputOffset inclusive, and any input bytes that may have been buffered during a previous update operation, are processed, with padding being applied. The result is stored in a new buffer. Upon finish, this method resets this cipher.
      Parameters:
      input - the input buffer.
      inputOffset - the offset in input where the input starts.
      inputLen - the input length.
      Returns:
      the new buffer with the result.
      Throws:
      GeneralSecurityException - if this encryption algorithm is unable to proceed properly.