public class ChaCha20ParameterSpec
extends javax.crypto.spec.IvParameterSpec
This class represents parameters for the ChaCha20 stream cipher as specified by RFC 7539.
The parameters are a 96 bit nonce value (also known as initialization vector) and a 32 bit block counter (default: 0; usually 0 or 1). It is also possible to use a 64 bit nonce value but RFC 7539 recommends to use 96 bits.
Constructor and Description |
---|
ChaCha20ParameterSpec(byte[] nonce)
Creates a ChaCha20ParameterSpec from the given nonce value.
|
ChaCha20ParameterSpec(byte[] nonce,
int blockCounter)
Creates a ChaCha20ParameterSpec from the given nonce and blockCounter values.
|
Modifier and Type | Method and Description |
---|---|
int |
getBlockCounter()
Gets the blockCounter value.
|
byte[] |
getNonce()
Gets the nonce value.
|
public ChaCha20ParameterSpec(byte[] nonce, int blockCounter)
nonce
- the nonce valueblockCounter
- the blockCounterjava.lang.IllegalArgumentException
- if nonce
is not 96 or 64 bit long or
blockCounter
is negativepublic ChaCha20ParameterSpec(byte[] nonce)
nonce
- the nonce valuejava.lang.IllegalArgumentException
- if nonce
is not 96 or 64 bit long