Class ChachaPolyCipher

java.lang.Object
net.schmizz.sshj.transport.cipher.BaseCipher
com.hierynomus.sshj.transport.cipher.ChachaPolyCipher
All Implemented Interfaces:
Cipher

public class ChachaPolyCipher extends BaseCipher
  • Field Details

    • CHACHA_KEY_SIZE

      private static final int CHACHA_KEY_SIZE
      See Also:
    • AAD_LENGTH

      private static final int AAD_LENGTH
      See Also:
    • POLY_TAG_LENGTH

      private static final int POLY_TAG_LENGTH
      See Also:
    • CIPHER_CHACHA

      private static final String CIPHER_CHACHA
      See Also:
    • MAC_POLY1305

      private static final String MAC_POLY1305
      See Also:
    • POLY_KEY_INPUT

      private static final byte[] POLY_KEY_INPUT
    • authSize

      private final int authSize
    • encryptedAad

      private byte[] encryptedAad
    • mode

      protected Cipher.Mode mode
    • aadCipher

      protected Cipher aadCipher
    • mac

      protected Mac mac
    • cipherKey

      protected Key cipherKey
    • aadCipherKey

      protected Key aadCipherKey
  • Constructor Details

    • ChachaPolyCipher

      public ChachaPolyCipher(int authSize, int bsize, String algorithm)
  • Method Details

    • getAuthenticationTagSize

      public int getAuthenticationTagSize()
      Specified by:
      getAuthenticationTagSize in interface Cipher
      Overrides:
      getAuthenticationTagSize in class BaseCipher
      Returns:
      Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication
    • setSequenceNumber

      public void setSequenceNumber(long seq)
      Specified by:
      setSequenceNumber in interface Cipher
      Overrides:
      setSequenceNumber in class BaseCipher
    • initCipher

      protected void initCipher(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)