Class InsecureNonceChaCha20


  • public class InsecureNonceChaCha20
    extends java.lang.Object
    A stream cipher, as described in RFC 8439 https://tools.ietf.org/html/rfc8439, section 2.4.

    This cipher is meant to be used to construct an AEAD with Poly1305.

    • Constructor Summary

      Constructors 
      Constructor Description
      InsecureNonceChaCha20​(byte[] key, int initialCounter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] createInitialState​(int[] nonce, int counter)  
      byte[] decrypt​(byte[] nonce, byte[] ciphertext)
      Decrypts ciphertext using nonce.
      byte[] decrypt​(byte[] nonce, java.nio.ByteBuffer ciphertext)
      Decrypts ciphertext using nonce.
      byte[] encrypt​(byte[] nonce, byte[] plaintext)
      Encrypts plaintext using nonce.
      void encrypt​(java.nio.ByteBuffer output, byte[] nonce, byte[] plaintext)
      Encrypts plaintext using nonce and writes result to output.
      int nonceSizeInBytes()  
      • Methods inherited from class java.lang.Object

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

      • InsecureNonceChaCha20

        public InsecureNonceChaCha20​(byte[] key,
                                     int initialCounter)
                              throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
    • Method Detail

      • createInitialState

        public int[] createInitialState​(int[] nonce,
                                        int counter)
      • nonceSizeInBytes

        public int nonceSizeInBytes()
      • encrypt

        public byte[] encrypt​(byte[] nonce,
                              byte[] plaintext)
                       throws java.security.GeneralSecurityException
        Encrypts plaintext using nonce.
        Throws:
        java.security.GeneralSecurityException
      • encrypt

        public void encrypt​(java.nio.ByteBuffer output,
                            byte[] nonce,
                            byte[] plaintext)
                     throws java.security.GeneralSecurityException
        Encrypts plaintext using nonce and writes result to output.
        Throws:
        java.security.GeneralSecurityException
      • decrypt

        public byte[] decrypt​(byte[] nonce,
                              byte[] ciphertext)
                       throws java.security.GeneralSecurityException
        Decrypts ciphertext using nonce.
        Throws:
        java.security.GeneralSecurityException
      • decrypt

        public byte[] decrypt​(byte[] nonce,
                              java.nio.ByteBuffer ciphertext)
                       throws java.security.GeneralSecurityException
        Decrypts ciphertext using nonce.
        Throws:
        java.security.GeneralSecurityException