Class InsecureNonceChaCha20Poly1305Jce
- java.lang.Object
-
- com.google.crypto.tink.aead.internal.InsecureNonceChaCha20Poly1305Jce
-
@Immutable public final class InsecureNonceChaCha20Poly1305Jce extends java.lang.ObjectImplements ChaCha20Poly1305, as described in RFC 8439, section 2.8.It is similar to
ChaCha20Poly1305Jce, but it offers an interface for the user to choose the nonce, which is needed in HPKE.It uses the JCE, and requires that algorithm "ChaCha20-Poly1305" is present.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InsecureNonceChaCha20Poly1305Jcecreate(byte[] key)byte[]decrypt(byte[] nonce, byte[] ciphertext, byte[] associatedData)DecryptsciphertextwithnonceandassociatedData.byte[]decrypt(byte[] nonce, byte[] ciphertextWithPrefix, int ciphertextOffset, byte[] associatedData)DecryptsciphertextWithPrefixwithnonceandassociatedData.byte[]encrypt(byte[] nonce, byte[] plaintext, byte[] associatedData)EncryptsplaintextwithnonceandassociatedData.byte[]encrypt(byte[] nonce, byte[] plaintext, int ciphertextOffset, byte[] associatedData)EncryptsplaintextwithnonceandassociatedData.static booleanisSupported()
-
-
-
Method Detail
-
create
public static InsecureNonceChaCha20Poly1305Jce create(byte[] key) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
isSupported
public static boolean isSupported()
-
encrypt
public byte[] encrypt(byte[] nonce, byte[] plaintext, byte[] associatedData) throws java.security.GeneralSecurityExceptionEncryptsplaintextwithnonceandassociatedData.- Throws:
java.security.GeneralSecurityException
-
encrypt
public byte[] encrypt(byte[] nonce, byte[] plaintext, int ciphertextOffset, byte[] associatedData) throws java.security.GeneralSecurityExceptionEncryptsplaintextwithnonceandassociatedData.The
ciphertextOffsetis the offset at which the ciphertext will start in the returned byte array.- Throws:
java.security.GeneralSecurityException
-
decrypt
public byte[] decrypt(byte[] nonce, byte[] ciphertext, byte[] associatedData) throws java.security.GeneralSecurityExceptionDecryptsciphertextwithnonceandassociatedData.- Throws:
java.security.GeneralSecurityException
-
decrypt
public byte[] decrypt(byte[] nonce, byte[] ciphertextWithPrefix, int ciphertextOffset, byte[] associatedData) throws java.security.GeneralSecurityExceptionDecryptsciphertextWithPrefixwithnonceandassociatedData.The
ciphertextOffsetis the offset at which the ciphertext starts in theciphertextWithPrefix.- Throws:
java.security.GeneralSecurityException
-
-