public class ChaCha20Poly1305Parameters
extends java.security.AlgorithmParametersSpi
Whereas transparent ChaCha20Poly1305 parameters
may contain additional associated data and nonce value, the DER encoded opaque
parameter representation contains the nonce value only according to RFC 8103
(Using ChaCha20-Poly1305 Authenticated Encryption in the Cryptographic Message
Syntax (CMS)):
AEADChaCha20Poly1305Nonce ::= OCTET STRING (SIZE(12))
ChaCha20Poly1305Parameters can be generated by calling one of the AlgorithmParameters.getInstance
methods. Subsequently the new AlgorithmParameters object must be initialized with
a proper parameter specification (class ChaCha20Poly1305ParameterSpec is recommended) or a DER encoded
byte array, e.g.
ChaCha20Poly1305ParameterSpec chaCha20Poly1305ParameterSpec = ...;
AlgorithmParameters params = AlgorithmParameters.getInstance("ChaCha20Poly1305", "IAIK");
params.init(chaCha20Poly1305ParameterSpec);
The CCMParameters can also be initialized with an IvParameterSpec object. In this case, the specified IV
will be used as nonce.
| Constructor and Description |
|---|
ChaCha20Poly1305Parameters() |
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
engineGetEncoded()
Returns the parameters as DER byte array.
|
protected byte[] |
engineGetEncoded(java.lang.String format)
Returns the parameters as a DER byte array.
|
protected java.security.spec.AlgorithmParameterSpec |
engineGetParameterSpec(java.lang.Class paramSpec)
Returns the parameters as transparent parameter specification of the
given class type.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes this parameters object using the parameters specified in paramSpec.
|
protected void |
engineInit(byte[] params)
Inits the parameters from an DER encoded byte array.
|
protected void |
engineInit(byte[] params,
java.lang.String format)
Inits the parameters from an DER encoded byte array.
|
protected java.lang.String |
engineToString()
Returns a formatted string describing the parameters.
|
protected void engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
throws java.security.spec.InvalidParameterSpecException
engineInit in class java.security.AlgorithmParametersSpiparamSpec - the parameter specification - must be ChaCha20Poly1305ParameterSpec
or IvParameterSpec.java.security.spec.InvalidParameterSpecException - if the given parameter specification is
inappropriate for the initialization of this parameter object
(not a ChaCha20Poly1305ParameterSpec, ChaCha20ParameterSpec or IvParameterSpec).protected void engineInit(byte[] params)
throws java.io.IOException
The DER encoded parameters must represent an ASN.1 OCTET_STRING containing the nonce value as specified by RFC 8103 (Using ChaCha20-Poly1305 Authenticated Encryption in the Cryptographic Message Syntax (CMS)):
AEADChaCha20Poly1305Nonce ::= OCTET STRING (SIZE(12))
engineInit in class java.security.AlgorithmParametersSpiparams - the DER encoded byte arrayjava.io.IOException - if an error occurs when decoding the given byte arrayprotected void engineInit(byte[] params,
java.lang.String format)
throws java.io.IOException
engineInit(params) for initializing this ChaCha20Poly1305Parameters
object from the given DER encoded byte array, regardless of what is specified
in the format string.
The DER encoded parameters must represent an ASN.1 OCTET_STRING containing the nonce value as specified by RFC 8103 (Using ChaCha20-Poly1305 Authenticated Encryption in the Cryptographic Message Syntax (CMS)):
AEADChaCha20Poly1305Nonce ::= OCTET STRING (SIZE(12))
engineInit in class java.security.AlgorithmParametersSpiparams - the DER encoded byte arrayformat - the encoding format; ignoredjava.io.IOException - if an error occurs when decoding the given byte arrayprotected java.security.spec.AlgorithmParameterSpec engineGetParameterSpec(java.lang.Class paramSpec)
throws java.security.spec.InvalidParameterSpecException
engineGetParameterSpec in class java.security.AlgorithmParametersSpiparamSpec - the desired parameter specification class
(ChaCha20Poly1305ParameterSpec or ChaCha20ParameterSpec or IvParameterSpec)ChaCha20Poly1305ParameterSpec or ChaCha20ParameterSpec or IvParameterSpecjava.security.spec.InvalidParameterSpecException - if the parameters cannot be converted to
the desired parameter specification
(must be a ChaCha20Poly1305ParameterSpec, ChaCha20ParameterSpec or IvParameterSpec).protected byte[] engineGetEncoded()
throws java.io.IOException
The encoded parameters returned by this method represent an ASN.1 OCTET_STRING containing the nonce value as specified by RFC 8103 (Using ChaCha20-Poly1305 Authenticated Encryption in the Cryptographic Message Syntax (CMS)):
AEADChaCha20Poly1305Nonce ::= OCTET STRING (SIZE(12))
engineGetEncoded in class java.security.AlgorithmParametersSpijava.io.IOException - if an encoding error occursprotected byte[] engineGetEncoded(java.lang.String format)
throws java.io.IOException
Format is ignored. Only DER encoding is supported at this time. This method
only calls engineGetEncoded(), regardless of what
is specified in the format string.
The encoded parameters returned by this method represent an ASN.1 OCTET_STRING containing the nonce value as specified by RFC 8103 (Using ChaCha20-Poly1305 Authenticated Encryption in the Cryptographic Message Syntax (CMS)):
AEADChaCha20Poly1305Nonce ::= OCTET STRING (SIZE(12))
engineGetEncoded in class java.security.AlgorithmParametersSpiformat - the encoding format; ignoredjava.io.IOException - if an encoding error occursprotected java.lang.String engineToString()
engineToString in class java.security.AlgorithmParametersSpi