Top Description Fields Constructors Methods
javax.crypto.spec

public final Class ChaCha20ParameterSpec

extends Object
implements AlgorithmParameterSpec
Class Inheritance
All Implemented Interfaces
java.security.spec.AlgorithmParameterSpec
Imports
java.security.spec.AlgorithmParameterSpec, java.util.Objects

This class specifies the parameters used with the ChaCha20 algorithm.

The parameters consist of a 12-byte nonce and an initial counter value expressed as a 32-bit integer.

This class can be used to initialize a Cipher object that implements the ChaCha20 algorithm.

Since
11

Field Summary

Modifier and TypeField and Description
private final int
private final byte[]
private static final int

Constructor Summary

AccessConstructor and Description
public
ChaCha20ParameterSpec(byte[]
a 12-byte nonce value
nonce
,
int
the initial counter value
counter
)

Constructs a parameter set for ChaCha20 from the given nonce and counter.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the counter value
getCounter
()

Returns the configured counter value.

public byte[]

Returns:

the nonce value. This method returns a new array each time this method is called.
getNonce
()

Returns the nonce value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

counterback to summary
private final int counter
nonceback to summary
private final byte[] nonce
NONCE_LENGTHback to summary
private static final int NONCE_LENGTH

Constructor Detail

ChaCha20ParameterSpecback to summary
public ChaCha20ParameterSpec(byte[] nonce, int counter)

Constructs a parameter set for ChaCha20 from the given nonce and counter.

Parameters
nonce:byte[]

a 12-byte nonce value

counter:int

the initial counter value

Exceptions
NullPointerException:
if nonce is null
IllegalArgumentException:
if nonce is not 12 bytes in length

Method Detail

getCounterback to summary
public int getCounter()

Returns the configured counter value.

Returns:int

the counter value

getNonceback to summary
public byte[] getNonce()

Returns the nonce value.

Returns:byte[]

the nonce value. This method returns a new array each time this method is called.