@Immutable public final class InsecureNonceChaCha20Poly1305Jce extends Object
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.
| Modifier and Type | Method and Description |
|---|---|
static InsecureNonceChaCha20Poly1305Jce |
create(byte[] key) |
byte[] |
decrypt(byte[] nonce,
byte[] ciphertext,
byte[] associatedData)
Decrypts
ciphertext with nonce and associatedData. |
byte[] |
decrypt(byte[] nonce,
byte[] ciphertextWithPrefix,
int ciphertextOffset,
byte[] associatedData)
Decrypts
ciphertextWithPrefix with nonce and associatedData. |
byte[] |
encrypt(byte[] nonce,
byte[] plaintext,
byte[] associatedData)
Encrypts
plaintext with nonce and associatedData. |
byte[] |
encrypt(byte[] nonce,
byte[] plaintext,
int ciphertextOffset,
byte[] associatedData)
Encrypts
plaintext with nonce and associatedData. |
static boolean |
isSupported() |
public static InsecureNonceChaCha20Poly1305Jce create(byte[] key) throws GeneralSecurityException
GeneralSecurityExceptionpublic static boolean isSupported()
public byte[] encrypt(byte[] nonce,
byte[] plaintext,
byte[] associatedData)
throws GeneralSecurityException
plaintext with nonce and associatedData.GeneralSecurityExceptionpublic byte[] encrypt(byte[] nonce,
byte[] plaintext,
int ciphertextOffset,
byte[] associatedData)
throws GeneralSecurityException
plaintext with nonce and associatedData.
The ciphertextOffset is the offset at which the ciphertext will start in the
returned byte array.
GeneralSecurityExceptionpublic byte[] decrypt(byte[] nonce,
byte[] ciphertext,
byte[] associatedData)
throws GeneralSecurityException
ciphertext with nonce and associatedData.GeneralSecurityExceptionpublic byte[] decrypt(byte[] nonce,
byte[] ciphertextWithPrefix,
int ciphertextOffset,
byte[] associatedData)
throws GeneralSecurityException
ciphertextWithPrefix with nonce and associatedData.
The ciphertextOffset is the offset at which the ciphertext starts in the ciphertextWithPrefix.
GeneralSecurityException