APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.crypto.provider

public final Class ChaCha20Poly1305Parameters

extends AlgorithmParametersSpi
Class Inheritance
Imports
java.io.IOException, java.security.AlgorithmParametersSpi, java.security.spec.AlgorithmParameterSpec, .InvalidParameterSpecException, javax.crypto.spec.IvParameterSpec, sun.security.util.*

This class implements the parameter set used with the ChaCha20-Poly1305 algorithm. The parameter definition comes from RFC 8103 and is defined according to the following ASN.1:
id-alg-AEADChaCha20Poly1305 OBJECT IDENTIFIER ::=
       { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1)
         pkcs9(9) smime(16) alg(3) 18 }

AEADChaCha20Poly1305Nonce ::= OCTET STRING (SIZE(12))
The AlgorithmParameters may be instantiated either by its name ("ChaCha20-Poly1305") or via its OID (1.2.840.113549.1.9.16.3.18)

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected byte[]

Returns:

a byte array containing the DER-encoding for the ChaCha20-Poly1305 parameters. This will be the nonce encoded as a DER OCTET STRING.
engineGetEncoded
()

Implements abstract java.security.AlgorithmParametersSpi.engineGetEncoded.

Return the encoded parameters in ASN.1 form.

protected byte[]

Returns:

a byte array containing the DER-encoding for the ChaCha20-Poly1305 parameters.
engineGetEncoded
(String
the encoding method to be used. This parameter must be "ASN.1" as it is the only currently supported encoding format. If the parameter is null then the default encoding format will be used.
encodingMethod
)

Implements abstract java.security.AlgorithmParametersSpi.engineGetEncoded.

Return the encoded parameters in ASN.1 form.

protected <T extends AlgorithmParameterSpec> T

Returns:

a IvParameterSpec object containing the nonce value held in this object.
engineGetParameterSpec
(Class<T>
the class name of the spec. In this case it should be IvParameterSpec.class.
paramSpec
)

Implements abstract java.security.AlgorithmParametersSpi.engineGetParameterSpec.

Return an IvParameterSpec with the same parameters as those held in this object.

protected void
engineInit(AlgorithmParameterSpec
the IvParameterSpec used to configure this object.
paramSpec
)

Implements abstract java.security.AlgorithmParametersSpi.engineInit.

Initialize the ChaCha20Poly1305Parameters using an IvParameterSpec.

protected void
engineInit(byte[]
the DER encoding of the nonce as an OCTET STRING.
encoded
)

Implements abstract java.security.AlgorithmParametersSpi.engineInit.

Initialize the ChaCha20Poly1305Parameters from a DER encoded parameter block.

protected void
engineInit(byte[]
the DER encoding of the nonce and initial block counter.
encoded
,
String
the decoding method. The only currently accepted value is "ASN.1"
decodingMethod
)

Implements abstract java.security.AlgorithmParametersSpi.engineInit.

Initialize the ChaCha20Poly1305Parameters from a DER encoded parameter block.

protected String

Returns:

a string representation of the ChaCha20 parameters.
engineToString
()

Implements abstract java.security.AlgorithmParametersSpi.engineToString.

Creates a formatted string describing the parameters.

Field Detail

DEFAULT_FMTback to summary
private static final String DEFAULT_FMT
nonceback to summary
private byte[] nonce

Constructor Detail

ChaCha20Poly1305Parametersback to summary
public ChaCha20Poly1305Parameters()

Method Detail

engineGetEncodedback to summary
protected byte[] engineGetEncoded() throws IOException

Implements abstract java.security.AlgorithmParametersSpi.engineGetEncoded.

Return the encoded parameters in ASN.1 form.

Returns:byte[]

a byte array containing the DER-encoding for the ChaCha20-Poly1305 parameters. This will be the nonce encoded as a DER OCTET STRING.

Annotations
@Override
Exceptions
IOException:
if any DER encoding error occurs.
engineGetEncodedback to summary
protected byte[] engineGetEncoded(String encodingMethod) throws IOException

Implements abstract java.security.AlgorithmParametersSpi.engineGetEncoded.

Return the encoded parameters in ASN.1 form.

Parameters
encodingMethod:String

the encoding method to be used. This parameter must be "ASN.1" as it is the only currently supported encoding format. If the parameter is null then the default encoding format will be used.

Returns:byte[]

a byte array containing the DER-encoding for the ChaCha20-Poly1305 parameters.

Annotations
@Override
Exceptions
IOException:
if any DER encoding error occurs or an unsupported encoding method is provided.
engineGetParameterSpecback to summary
protected <T extends AlgorithmParameterSpec> T engineGetParameterSpec(Class<T> paramSpec) throws InvalidParameterSpecException

Implements abstract java.security.AlgorithmParametersSpi.engineGetParameterSpec.

Return an IvParameterSpec with the same parameters as those held in this object.

Parameters
paramSpec:Class<T>

the class name of the spec. In this case it should be IvParameterSpec.class.

Returns:T

a IvParameterSpec object containing the nonce value held in this object.

Annotations
@Override
Exceptions
InvalidParameterSpecException:
if a class other than IvParameterSpec.class was specified in the paramSpec parameter.
engineInitback to summary
protected void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException

Implements abstract java.security.AlgorithmParametersSpi.engineInit.

Initialize the ChaCha20Poly1305Parameters using an IvParameterSpec.

Parameters
paramSpec:AlgorithmParameterSpec

the IvParameterSpec used to configure this object.

Annotations
@Override
Exceptions
InvalidParameterSpecException:
if an object of a type other than IvParameterSpec is used.
engineInitback to summary
protected void engineInit(byte[] encoded) throws IOException

Implements abstract java.security.AlgorithmParametersSpi.engineInit.

Initialize the ChaCha20Poly1305Parameters from a DER encoded parameter block.

Parameters
encoded:byte[]

the DER encoding of the nonce as an OCTET STRING.

Annotations
@Override
Exceptions
IOException:
if the encoded nonce is not 12 bytes long or a DER decoding error occurs.
engineInitback to summary
protected void engineInit(byte[] encoded, String decodingMethod) throws IOException

Implements abstract java.security.AlgorithmParametersSpi.engineInit.

Initialize the ChaCha20Poly1305Parameters from a DER encoded parameter block.

Parameters
encoded:byte[]

the DER encoding of the nonce and initial block counter.

decodingMethod:String

the decoding method. The only currently accepted value is "ASN.1"

Annotations
@Override
Exceptions
IOException:
if the encoded nonce is not 12 bytes long, a DER decoding error occurs, or an unsupported decoding method is provided.
engineToStringback to summary
protected String engineToString()

Implements abstract java.security.AlgorithmParametersSpi.engineToString.

Creates a formatted string describing the parameters.

Returns:String

a string representation of the ChaCha20 parameters.

Annotations
@Override