public class ChaCha20Poly1305ParameterSpec extends ChaCha20ParameterSpec
The parameters are a 96 bit nonce value (also known as initialization vector) and additional associated data.
Note that associated data may be supplied to the ChaCha20Poly1305 Cipher only either by means of a
ChaCha20Poly1305ParameterSpec or by calling chacha20Poly1305Cipher.updateAAD()
.
Supplying associated data by both ChaCha20Poly1305ParameterSpec and calling
chacha20Poly1305Cipher.updateAAD()
is not allowed.
If associated data is specified by a ChaCha20Poly1305ParameterSpec the associated data
is also included in the parameters got from a ChaCha20Poly1305 Cipher when calling
chacha20Poly1305Cipher.getParameters()
. However, associated data that
has been supplied by calling chacha20Poly1305Cipher.updateAAD()
is not included in the parameters got from a ChaCha20Poly1305 Cipher when calling
chacha20Poly1305Cipher.getParameters()
.
Constructor and Description |
---|
ChaCha20Poly1305ParameterSpec(byte[] nonce)
Creates a ChaCha20Poly1305ParameterSpec from the given nonce value.
|
ChaCha20Poly1305ParameterSpec(byte[] aaData,
byte[] nonce)
Creates a ChaCha20Poly1305ParameterSpec from additional associated data
(aad) and the nonce.
|
ChaCha20Poly1305ParameterSpec(byte[] aaData,
byte[] nonce,
int blockCounter)
Creates a ChaCha20Poly1305ParameterSpec from additional associated data
(aad), nonce and ChaCha20 block counter.
|
ChaCha20Poly1305ParameterSpec(byte[] nonce,
int blockCounter)
Creates a ChaCha20Poly1305ParameterSpec from the given nonce value and ChaCha20 block counter.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getAAD()
Gets any additional associated data.
|
byte[] |
getNonce()
Gets the nonce value.
|
getBlockCounter
public ChaCha20Poly1305ParameterSpec(byte[] nonce)
nonce
- the noncejava.lang.IllegalArgumentException
- if nonce
is not 96 bit longpublic ChaCha20Poly1305ParameterSpec(byte[] nonce, int blockCounter)
nonce
- the nonceblockCounter
- the blockCounter (default: 0)java.lang.IllegalArgumentException
- if nonce
is not 96 bit long or
or blockCounter
is negativepublic ChaCha20Poly1305ParameterSpec(byte[] aaData, byte[] nonce)
Note that associated data may be supplied to the ChaCha20Poly1305 Cipher only either by means of a
ChaCha20Poly1305ParameterSpec or by calling chacha20Poly1305Cipher.updateAAD()
.
Supplying associated data by both ChaCha20Poly1305ParameterSpec and calling
chacha20Poly1305Cipher.updateAAD()
is not allowed.
If associated data is specified by a ChaCha20Poly130ParameterSpec the associated data
is also included in the parameters got from a ChaCha20Poly1305 Cipher when calling
chacha20Poly1305Cipher.getParameters()
. However, associated data that
has been supplied by calling chacha20Poly1305Cipher.updateAAD()
is not included in the parameters got from a ChaCha20Poly1305 Cipher when calling
chacha20Poly1305Cipher.getParameters()
.
aaData
- the additional associated datanonce
- the noncejava.lang.IllegalArgumentException
- if nonce
is not 96 bit longpublic ChaCha20Poly1305ParameterSpec(byte[] aaData, byte[] nonce, int blockCounter)
Note that associated data may be supplied to the ChaCha20Poly1305 Cipher only either by means of a
ChaCha20Poly1305ParameterSpec or by calling chacha20Poly1305Cipher.updateAAD()
.
Supplying associated data by both ChaCha20Poly1305ParameterSpec and calling
chacha20Poly1305Cipher.updateAAD()
is not allowed.
If associated data is specified by a ChaCha20Poly130ParameterSpec the associated data
is also included in the parameters got from a ChaCha20Poly1305 Cipher when calling
chacha20Poly1305Cipher.getParameters()
. However, associated data that
has been supplied by calling chacha20Poly1305Cipher.updateAAD()
is not included in the parameters got from a ChaCha20Poly1305 Cipher when calling
chacha20Poly1305Cipher.getParameters()
.
aaData
- the additional associated datanonce
- the nonceblockCounter
- the blockCounter (default: 0)java.lang.IllegalArgumentException
- if nonce
is not 96 bit long or
blockCounter
is not 0public byte[] getNonce()
getNonce
in class ChaCha20ParameterSpec
public byte[] getAAD()
null
if no
additional associated data has been set