Interface Cipher

    • Method Detail

      • init

        void init​(Cipher.Mode mode,
                  byte[] key,
                  byte[] iv)
           throws Exception
        Initialize the cipher for encryption or decryption with the given key and initialization vector
        Parameters:
        mode - Encrypt/Decrypt initialization
        key - Key bytes
        iv - Initialization vector bytes
        Throws:
        Exception - If failed to initialize
      • update

        default void update​(byte[] input)
                     throws Exception
        Performs in-place encryption or decryption on the given data.
        Parameters:
        input - The input/output bytes
        Throws:
        Exception - If failed to execute
        See Also:
        update(byte[], int, int)
      • update

        void update​(byte[] input,
                    int inputOffset,
                    int inputLen)
             throws Exception
        Performs in-place encryption or decryption on the given data.
        Parameters:
        input - The input/output bytes
        inputOffset - The offset of the data in the data buffer
        inputLen - The number of bytes to update - starting at the given offset
        Throws:
        Exception - If failed to execute
      • updateAAD

        default void updateAAD​(byte[] data)
                        throws Exception
        Adds the provided input data as additional authenticated data during encryption or decryption.
        Parameters:
        data - The data to authenticate
        Throws:
        Exception - If failed to execute
      • updateAAD

        void updateAAD​(byte[] data,
                       int offset,
                       int length)
                throws Exception
        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
        Throws:
        Exception - If failed to execute
      • updateWithAAD

        default void updateWithAAD​(byte[] input,
                                   int offset,
                                   int aadLen,
                                   int inputLen)
                            throws Exception
        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
        Throws:
        Exception - If failed to execute
      • checkSupported

        static boolean checkSupported​(String xform,
                                      int keyLength)
        Parameters:
        xform - The full cipher transformation - e.g., AES/CBC/NoPadding - never null/empty
        keyLength - The required key length in bits - always positive
        Returns:
        true if the cipher transformation and required key length are supported
        See Also:
        Cipher.getMaxAllowedKeyLength(String)