public class InsecureNonceChaCha20 extends Object
This cipher is meant to be used to construct an AEAD with Poly1305.
| Constructor and Description |
|---|
InsecureNonceChaCha20(byte[] key,
int initialCounter) |
| Modifier and Type | Method and Description |
|---|---|
int[] |
createInitialState(int[] nonce,
int counter)
Returns the initial state from
nonce and counter. |
byte[] |
decrypt(byte[] nonce,
byte[] ciphertext)
Decrypts
ciphertext using nonce. |
byte[] |
decrypt(byte[] nonce,
ByteBuffer ciphertext)
Decrypts
ciphertext using nonce. |
byte[] |
encrypt(byte[] nonce,
byte[] plaintext)
Encrypts
plaintext using nonce. |
void |
encrypt(ByteBuffer output,
byte[] nonce,
byte[] plaintext)
Encrypts
plaintext using nonce and writes result to output. |
int |
nonceSizeInBytes()
The size of the randomly generated nonces.
|
public InsecureNonceChaCha20(byte[] key,
int initialCounter)
throws InvalidKeyException
InvalidKeyExceptionpublic int[] createInitialState(int[] nonce,
int counter)
nonce and counter.public int nonceSizeInBytes()
ChaCha20 uses 12-byte nonces, but XChaCha20 use 24-byte nonces.
public byte[] encrypt(byte[] nonce,
byte[] plaintext)
throws GeneralSecurityException
plaintext using nonce.GeneralSecurityExceptionpublic void encrypt(ByteBuffer output, byte[] nonce, byte[] plaintext) throws GeneralSecurityException
plaintext using nonce and writes result to output.GeneralSecurityExceptionpublic byte[] decrypt(byte[] nonce,
byte[] ciphertext)
throws GeneralSecurityException
ciphertext using nonce.GeneralSecurityExceptionpublic byte[] decrypt(byte[] nonce,
ByteBuffer ciphertext)
throws GeneralSecurityException
ciphertext using nonce.GeneralSecurityException