public final class InsecureNonceChaCha20Poly1305 extends Object
| Modifier and Type | Field and Description |
|---|---|
static TinkFipsUtil.AlgorithmFipsCompatibility |
FIPS |
| Constructor and Description |
|---|
InsecureNonceChaCha20Poly1305(byte[] key) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] nonce,
byte[] ciphertext,
byte[] associatedData)
Decrypts
ciphertext with the following format: actual_ciphertext || tag. |
byte[] |
decrypt(ByteBuffer ciphertext,
byte[] nonce,
byte[] associatedData)
Decrypts
ciphertext with the following format: actual_ciphertext || tag. |
byte[] |
encrypt(byte[] nonce,
byte[] plaintext,
byte[] associatedData)
Encrypts
plaintext with Poly1305 authentication based on associatedData. |
void |
encrypt(ByteBuffer output,
byte[] nonce,
byte[] plaintext,
byte[] associatedData)
Encrypts
plaintext with Poly1305 authentication based on associatedData. |
public static final TinkFipsUtil.AlgorithmFipsCompatibility FIPS
public InsecureNonceChaCha20Poly1305(byte[] key)
throws GeneralSecurityException
GeneralSecurityExceptionpublic byte[] encrypt(byte[] nonce,
byte[] plaintext,
byte[] associatedData)
throws GeneralSecurityException
plaintext with Poly1305 authentication based on associatedData.
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.
nonce - specified by callerplaintext - data to encryptassociatedData - associated authenticated dataactual_ciphertext || tagGeneralSecurityExceptionpublic void encrypt(ByteBuffer output, byte[] nonce, byte[] plaintext, byte[] associatedData) throws GeneralSecurityException
plaintext with Poly1305 authentication based on associatedData.
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.
output - ciphertext buffer with the following format actual_ciphertext || tagnonce - specified by callerplaintext - data to encryptassociatedData - associated authenticated dataGeneralSecurityExceptionpublic byte[] decrypt(byte[] nonce,
byte[] ciphertext,
byte[] associatedData)
throws GeneralSecurityException
ciphertext with the following format: actual_ciphertext || tag.nonce - specified by callerciphertext - with format actual_ciphertext || tagassociatedData - associated authenticated dataGeneralSecurityException - when ciphertext is shorter than tag size or when
computed tag based on ciphertext and associatedData does not match the tag
given in ciphertext.public byte[] decrypt(ByteBuffer ciphertext, byte[] nonce, byte[] associatedData) throws GeneralSecurityException
ciphertext with the following format: actual_ciphertext || tag.ciphertext - with format actual_ciphertext || tagnonce - specified by callerassociatedData - associated authenticated dataGeneralSecurityException - when ciphertext is shorter than tag sizeAEADBadTagException - when the tag is invalid