Class ChachaPolyCipher

  • All Implemented Interfaces:
    Cipher

    public class ChachaPolyCipher
    extends BaseCipher
    • Field Detail

      • POLY_KEY_INPUT

        private static final byte[] POLY_KEY_INPUT
      • authSize

        private final int authSize
      • encryptedAad

        private byte[] encryptedAad
      • aadCipher

        protected javax.crypto.Cipher aadCipher
      • mac

        protected javax.crypto.Mac mac
      • cipherKey

        protected java.security.Key cipherKey
      • aadCipherKey

        protected java.security.Key aadCipherKey
    • Constructor Detail

      • ChachaPolyCipher

        public ChachaPolyCipher​(int authSize,
                                int bsize,
                                java.lang.String algorithm)
    • Method Detail

      • initCipher

        protected void initCipher​(javax.crypto.Cipher cipher,
                                  Cipher.Mode mode,
                                  byte[] key,
                                  byte[] iv)
        Specified by:
        initCipher in class BaseCipher
      • updateAAD

        public void updateAAD​(byte[] data,
                              int offset,
                              int length)
        Description copied from interface: Cipher
        Adds the provided input data as additional authenticated data during encryption or decryption.
        Specified by:
        updateAAD in interface Cipher
        Overrides:
        updateAAD in class BaseCipher
        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

        public void updateAAD​(byte[] data)
        Description copied from interface: Cipher
        Adds the provided input data as additional authenticated data during encryption or decryption.
        Specified by:
        updateAAD in interface Cipher
        Overrides:
        updateAAD in class BaseCipher
        Parameters:
        data - The data to authenticate
      • update

        public void update​(byte[] input,
                           int inputOffset,
                           int inputLen)
        Description copied from interface: Cipher
        Performs in-place encryption or decryption on the given data.
        Specified by:
        update in interface Cipher
        Overrides:
        update in class BaseCipher
        Parameters:
        input - the subject
        inputOffset - offset at which to start
        inputLen - number of bytes starting at inputOffset
      • longToBytes

        private byte[] longToBytes​(long lng)