| Constructor and Description |
|---|
XChaCha20Poly1305(byte[] key) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] ciphertext,
byte[] associatedData)
Decryptes
ciphertext with the following format: nonce || actual_ciphertext ||
tag |
byte[] |
encrypt(byte[] plaintext,
byte[] associatedData)
Encrypts the
plaintext with Poly1305 authentication based on associatedData. |
public XChaCha20Poly1305(byte[] key)
throws InvalidKeyException
InvalidKeyExceptionpublic byte[] encrypt(byte[] plaintext,
byte[] associatedData)
throws GeneralSecurityException
plaintext with Poly1305 authentication based on associatedData.
Please note that nonce is randomly generated hence keys need to be rotated after encrypting
a certain number of messages depending on the nonce size of the underlying ChaCha20Base.
encrypt in interface Aeadplaintext - data to encryptassociatedData - associated authenticated datanonce || actual_ciphertext || tagGeneralSecurityExceptionpublic byte[] decrypt(byte[] ciphertext,
byte[] associatedData)
throws GeneralSecurityException
ciphertext with the following format: nonce || actual_ciphertext ||
tagdecrypt in interface Aeadciphertext - with format nonce || actual_ciphertext || tagassociatedData - associated authenticated dataGeneralSecurityException - when ciphertext is shorter than nonce size + tag size or when
computed tag based on ciphertext and associatedData does not match the tag
given in ciphertext.