Class AesCTRTransformer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BLOCK_SIZE
      Salmon stream encryption block size, same as AES.
      static int EXPANDED_KEY_SIZE
      Standard expansion key size for AES256 only.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getBlock()
      Get the current block.
      byte[] getCounter()
      Get the current Counter.
      protected byte[] getExpandedKey()
      Get the expanded key if available.
      byte[] getKey()
      Get the current encryption key.
      byte[] getNonce()
      Get the nonce (initial counter)
      protected void increaseCounter​(long value)
      Increase the Counter We use only big endianness for AES regardless of the machine architecture
      void init​(byte[] key, byte[] nonce)
      Initialize the transformer.
      void resetCounter()
      Resets the Counter and the block count.
      void setExpandedKey​(byte[] expandedKey)
      Set the expanded key.
      void syncCounter​(long position)
      Syncs the Counter based on what AES block position the stream is at.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EXPANDED_KEY_SIZE

        public static final int EXPANDED_KEY_SIZE
        Standard expansion key size for AES256 only.
        See Also:
        Constant Field Values
      • BLOCK_SIZE

        public static final int BLOCK_SIZE
        Salmon stream encryption block size, same as AES.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AesCTRTransformer

        public AesCTRTransformer()
    • Method Detail

      • resetCounter

        public void resetCounter()
        Resets the Counter and the block count.
        Specified by:
        resetCounter in interface ICTRTransformer
      • syncCounter

        public void syncCounter​(long position)
        Syncs the Counter based on what AES block position the stream is at. The block count is already excluding the header and the hash signatures.
        Specified by:
        syncCounter in interface ICTRTransformer
        Parameters:
        position - The position to sync the counter to
      • increaseCounter

        protected void increaseCounter​(long value)
        Increase the Counter We use only big endianness for AES regardless of the machine architecture
        Parameters:
        value - value to increase counter by
      • init

        public void init​(byte[] key,
                         byte[] nonce)
        Initialize the transformer. Most common operations include precalculating expansion keys or any other prior initialization for efficiency.
        Specified by:
        init in interface ICTRTransformer
        Parameters:
        key - The key
        nonce - The nonce
        Throws:
        SecurityException - Thrown if there is a security exception
      • getCounter

        public byte[] getCounter()
        Get the current Counter.
        Specified by:
        getCounter in interface ICTRTransformer
        Returns:
        The current counter
      • getBlock

        public long getBlock()
        Get the current block.
        Specified by:
        getBlock in interface ICTRTransformer
        Returns:
        The current block
      • getKey

        public byte[] getKey()
        Get the current encryption key.
        Specified by:
        getKey in interface ICTRTransformer
        Returns:
        The encryption key
      • getExpandedKey

        protected byte[] getExpandedKey()
        Get the expanded key if available.
        Returns:
        The expanded key
      • getNonce

        public byte[] getNonce()
        Get the nonce (initial counter)
        Specified by:
        getNonce in interface ICTRTransformer
        Returns:
        The nonce
      • setExpandedKey

        public void setExpandedKey​(byte[] expandedKey)
        Set the expanded key. This should be called once during initialization phase.
        Parameters:
        expandedKey - The expanded key