Interface Cipher

All Known Implementing Classes:
AES128CBC, AES128CTR, AES192CBC, AES192CTR, AES256CBC, AES256CTR, BaseCipher, BlockCipher, BlowfishCBC, ChachaPolyCipher, GcmCipher, NoneCipher, StreamCipher, TripleDESCBC

public interface Cipher
Wrapper for a cryptographic cipher, used either for encryption or decryption.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    int
     
    int
     
    void
    init(Cipher.Mode mode, byte[] key, byte[] iv)
    Initialize the cipher for encryption or decryption with the given private key and initialization vector
    void
     
    void
    update(byte[] input, int inputOffset, int inputLen)
    Performs in-place encryption or decryption on the given data.
    void
    updateAAD(byte[] data)
    Adds the provided input data as additional authenticated data during encryption or decryption.
    void
    updateAAD(byte[] data, int offset, int length)
    Adds the provided input data as additional authenticated data during encryption or decryption.
    void
    updateWithAAD(byte[] input, int offset, int aadLen, int inputLen)
    Performs in-place authenticated encryption or decryption with additional data (AEAD).
  • Method Details

    • getBlockSize

      int getBlockSize()
      Returns:
      the block size for this cipher
    • getIVSize

      int getIVSize()
      Returns:
      the size of the initialization vector
    • getAuthenticationTagSize

      int getAuthenticationTagSize()
      Returns:
      Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication
    • init

      void init(Cipher.Mode mode, byte[] key, byte[] iv)
      Initialize the cipher for encryption or decryption with the given private key and initialization vector
      Parameters:
      mode - whether this instance wil encrypt or decrypt
      key - the key for the cipher
      iv - initialization vector
    • update

      void update(byte[] input, int inputOffset, int inputLen)
      Performs in-place encryption or decryption on the given data.
      Parameters:
      input - the subject
      inputOffset - offset at which to start
      inputLen - number of bytes starting at inputOffset
    • updateAAD

      void updateAAD(byte[] data, int offset, int length)
      Adds the provided input data as additional authenticated data during encryption or decryption.
      Parameters:
      data - The additional data to authenticate
      offset - The offset of the additional data in the buffer
      length - The number of bytes in the buffer to use for authentication
    • updateAAD

      void updateAAD(byte[] data)
      Adds the provided input data as additional authenticated data during encryption or decryption.
      Parameters:
      data - The data to authenticate
    • updateWithAAD

      void updateWithAAD(byte[] input, int offset, int aadLen, int inputLen)
      Performs in-place authenticated encryption or decryption with additional data (AEAD). Authentication tags are implicitly appended after the output ciphertext or implicitly verified after the input ciphertext. Header data indicated by the aadLen parameter are authenticated but not encrypted/decrypted, while payload data indicated by the inputLen parameter are authenticated and encrypted/decrypted.
      Parameters:
      input - The input/output bytes
      offset - The offset of the data in the input buffer
      aadLen - The number of bytes to use as additional authenticated data - starting at offset
      inputLen - The number of bytes to update - starting at offset + aadLen
    • setSequenceNumber

      void setSequenceNumber(long seq)