public class GcmParameters
extends java.security.AlgorithmParametersSpi
For details on the individual GCM algorithm parameter values, refer to the transparent representation GCMParameterSpec.
This class provides the capability to convert GCM algorithm parameters to/from transparent representation. Currently, the following transparent algorithm parameter representations are supported:
This class also provides the capability to convert GCM algorithm parameters to/from encoded format. Currently, the following encoding/decoding formats are supported:
RFC 5084 defines the ASN.1 definition for GCM parameters which is provided
below. This encoding is designed for use with an AlgorithmID.
RFC 5084 also defines algorithm OIDs that support this GCM parameter
encoding:
GCMParameters ::= SEQUENCE {
aes-nonce OCTET STRING, -- recommended size is 12 octets
aes-ICVlen AES-GCM-ICVlen DEFAULT 12 }
AES-GCM-ICVlen ::= INTEGER (12 | 13 | 14 | 15 | 16)
aes OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840)
organization(1) gov(101) csor(3) nistAlgorithm(4) 1 }
id-aes128-GCM OBJECT IDENTIFIER ::= { aes 6 }
id-aes192-GCM OBJECT IDENTIFIER ::= { aes 26 }
id-aes256-GCM OBJECT IDENTIFIER ::= { aes 46 }
Note: RFC 5084 defines the parameter encoding for GCM parameters used with the AES symmetric cipher, which is currently the only supported symmetric cipher that also supports the GCM block mode. However, there is nothing in this encoding that is specific to the AES cipher. Thus, it is anticipated that this encoding may be used with other symmetric cipher implementations in the future.
An important purpose of this class is to provide access the parameters that
were used during an authenticated encryption or authenticated decryption
operation. In the case of authenticated encryption, this is the only way to
access the parameter values that are generated by the operation (i.e.
initialization vector and authentication tag length). But, in order to access the
individual parameter values, the opaque representation must first be
converted to transparent representation (i.e.
GCMParameterSpec).
To convert to GCMParameterSpec transparent representation
from DER-encoded ASN.1 representation, perform the following steps:
AlgorithmParameters.getInstance("GCM", "Entrust").AlgorithmParameters.init(byte[]).
To convert from GCMParameterSpec transparent
representation to DER-encoded ASN.1 representation, perform the following
steps:
AlgorithmParameters.getInstance("GCM", "Entrust").AlgorithmParameters.init(AlgorithmParameterSpec), where
AlgorithmParameterSpec is an instance of
GCMParameterSpec.AlgorithmParameters.getEncoded().
Note: GCM parameters in opaque representation can only be used with
the Cipher.init() API to initialize for authenticated
decryption; they cannot be used to initialize for authenticated encryption.
Refer to GCMParameterSpec for a transparent representation of
GCM parameters that can be used to initialize for authenticated encryption.
GcmBlockMechanism| Constructor and Description |
|---|
GcmParameters()
The constructor; creates a new instance of GCM algorithm parameters.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
engineGetEncoded()
Returns the parameters in their primary encoding format.
|
protected byte[] |
engineGetEncoded(java.lang.String format)
Returns the parameters encoded in the specified format.
|
protected <T extends java.security.spec.AlgorithmParameterSpec> |
engineGetParameterSpec(java.lang.Class<T> paramSpec)
Returns a (transparent) specification of this parameters object.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes this parameters object using the parameters specified in
paramSpec. |
protected void |
engineInit(byte[] params)
Imports the specified parameters and decodes them according to the
primary decoding format for the parameters.
|
protected void |
engineInit(byte[] params,
java.lang.String format)
Imports the parameters from
params and decodes them
according to the specified decoding format. |
protected java.lang.String |
engineToString()
Returns a formatted string describing the parameters.
|
public GcmParameters()
Applications should never use this constructor, instead the algorithm
parameters instance should be requested from the appropriate JCA/JCE
cryptographic service provider as follows:
AlgorithmParameters.getInstance("GCM", "Entrust").
protected void engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
throws java.security.spec.InvalidParameterSpecException
paramSpec.engineInit in class java.security.AlgorithmParametersSpiparamSpec - the parameter specificationjava.security.spec.InvalidParameterSpecException - if the given parameter specification is inappropriate for
the initialization of this parameter objectprotected void engineInit(byte[] params)
throws java.io.IOException
The primary decoding format for GCM parameters is ASN.1; details on this
format are provided in the class documentation (see GcmParameters
).
engineInit in class java.security.AlgorithmParametersSpiparams - the encoded parameters.java.io.IOException - on decoding errorsprotected void engineInit(byte[] params,
java.lang.String format)
throws java.io.IOException
params and decodes them
according to the specified decoding format.
If format is null, the primary decoding format for
parameters is used. The primary decoding format for GCM parameters is
ASN.1; details on this format are provided in the class documentation
(see GcmParameters). Currently, the following decoding formats
are supported: 'ASN.1'.
engineInit in class java.security.AlgorithmParametersSpiparams - the encoded parametersformat - the name of the decoding formatjava.io.IOException - if the decoding format is unsupported or a decoding error
occursprotected byte[] engineGetEncoded()
throws java.io.IOException
The primary encoding format for GCM parameters is ASN.1; details on this
format are provided in the class documentation (see GcmParameters
).
engineGetEncoded in class java.security.AlgorithmParametersSpijava.io.IOExceptionprotected byte[] engineGetEncoded(java.lang.String format)
throws java.io.IOException
If format is null, the primary encoding format for
parameters is used. The primary encoding format for GCM parameters is
ASN.1; details on this format are provided in the class documentation
(see GcmParameters). Currently, the following encoding formats
are supported: 'ASN.1'.
engineGetEncoded in class java.security.AlgorithmParametersSpiformat - the name of the encoding formatjava.io.IOException - if the encoding format is unsupportedprotected <T extends java.security.spec.AlgorithmParameterSpec> T engineGetParameterSpec(java.lang.Class<T> paramSpec)
throws java.security.spec.InvalidParameterSpecException
engineGetParameterSpec in class java.security.AlgorithmParametersSpiparamSpec - the specification class in which the parameters should be
returnedjava.security.spec.InvalidParameterSpecException - if the requested parameter specification is inappropriate for
this parameter objectprotected java.lang.String engineToString()
engineToString in class java.security.AlgorithmParametersSpi