Class InsecureNonceChaCha20Poly1305
- java.lang.Object
-
- com.google.crypto.tink.aead.internal.InsecureNonceChaCha20Poly1305
-
public final class InsecureNonceChaCha20Poly1305 extends java.lang.ObjectChaCha20Poly1305 AEAD construction, as described in RFC 8439, section 2.8.- Since:
- 1.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static TinkFipsUtil.AlgorithmFipsCompatibilityFIPS
-
Constructor Summary
Constructors Constructor Description InsecureNonceChaCha20Poly1305(byte[] key)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]decrypt(byte[] nonce, byte[] ciphertext, byte[] associatedData)Decryptsciphertextwith the following format:actual_ciphertext || tag.byte[]decrypt(java.nio.ByteBuffer ciphertext, byte[] nonce, byte[] associatedData)Decryptsciphertextwith the following format:actual_ciphertext || tag.byte[]encrypt(byte[] nonce, byte[] plaintext, byte[] associatedData)Encryptsplaintextwith Poly1305 authentication based onassociatedData.voidencrypt(java.nio.ByteBuffer output, byte[] nonce, byte[] plaintext, byte[] associatedData)Encryptsplaintextwith Poly1305 authentication based onassociatedData.
-
-
-
Field Detail
-
FIPS
public static final TinkFipsUtil.AlgorithmFipsCompatibility FIPS
-
-
Method Detail
-
encrypt
public byte[] encrypt(byte[] nonce, byte[] plaintext, byte[] associatedData) throws java.security.GeneralSecurityExceptionEncryptsplaintextwith Poly1305 authentication based onassociatedData.Please note that nonce should be randomly generated by the caller hence keys need to be rotated after encrypting a certain number of messages depending on the nonce size of the underlying
InsecureNonceChaCha20Base.- Parameters:
nonce- specified by callerplaintext- data to encryptassociatedData- associated authenticated data- Returns:
- ciphertext with the following format
actual_ciphertext || tag - Throws:
java.security.GeneralSecurityException
-
encrypt
public void encrypt(java.nio.ByteBuffer output, byte[] nonce, byte[] plaintext, byte[] associatedData) throws java.security.GeneralSecurityExceptionEncryptsplaintextwith Poly1305 authentication based onassociatedData.Please note that nonce should be randomly generated by the caller hence keys need to be rotated after encrypting a certain number of messages depending on the nonce size of the underlying
InsecureNonceChaCha20Base.- Parameters:
output- ciphertext buffer with the following formatactual_ciphertext || tagnonce- specified by callerplaintext- data to encryptassociatedData- associated authenticated data- Throws:
java.security.GeneralSecurityException
-
decrypt
public byte[] decrypt(byte[] nonce, byte[] ciphertext, byte[] associatedData) throws java.security.GeneralSecurityExceptionDecryptsciphertextwith the following format:actual_ciphertext || tag.- Parameters:
nonce- specified by callerciphertext- with formatactual_ciphertext || tagassociatedData- associated authenticated data- Returns:
- plaintext if authentication is successful.
- Throws:
java.security.GeneralSecurityException- when ciphertext is shorter than tag size or when computed tag based onciphertextandassociatedDatadoes not match the tag given inciphertext.
-
decrypt
public byte[] decrypt(java.nio.ByteBuffer ciphertext, byte[] nonce, byte[] associatedData) throws java.security.GeneralSecurityExceptionDecryptsciphertextwith the following format:actual_ciphertext || tag.- Parameters:
ciphertext- with formatactual_ciphertext || tagnonce- specified by callerassociatedData- associated authenticated data- Returns:
- plaintext if authentication is successful
- Throws:
java.security.GeneralSecurityException- when ciphertext is shorter than tag sizejavax.crypto.AEADBadTagException- when the tag is invalid
-
-