public class PKCS11GCMParameters
extends java.security.AlgorithmParametersSpi
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)
The aes-ICVLen specifies the length of the message authentication code value.
As stated in the NIST Special Publication 800-38D also the tag length of 4 and 8 bytes are possible.
GCMParameters 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 PKCS11GCMParameterSpec is recommended) or a DER encoded byte array, e.g.
IAIKPkcs11 iaikPcks11Provider = ...;
PKCS11GCMParameterSpec gcmParamSpec = ...;
AlgorithmParameters params = AlgorithmParameters.getInstance("GCM", iaikPcks11Provider);
params.init(gcmParamsSpec);
PKCS11GCMParameterSpec,
AlgorithmParametersSpi| Constructor and Description |
|---|
PKCS11GCMParameters()
The default constructor.
|
PKCS11GCMParameters(PKCS11GCMParameterSpec paramSpec)
Creates GCM Parameters with the given PCKS11GCMParameterSpec.
|
| 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 a GCM Parameter Specification of this GCM 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)
Initializes this GCMParameters object from the given 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 GCM Parameters.
|
static void |
setIncludeDefaultTagLengthInEncding(boolean include)
Decides whether the aes-ICVlen (tagLength) component should be
included when encoding GCM parameters if it has the default value (12 bytes).
|
public PKCS11GCMParameters()
AlgorithmParameters.getInstance for obtaining a GCMParameters object.public PKCS11GCMParameters(PKCS11GCMParameterSpec paramSpec)
paramSpec - the PKCS11GCMParameterSpecpublic static void setIncludeDefaultTagLengthInEncding(boolean include)
include - whether to include a default tagLength value (12 bytes)
when encoding GCM parameters or not (by default the
default value is not included)protected byte[] engineGetEncoded()
throws java.io.IOException
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.
engineGetEncoded in class java.security.AlgorithmParametersSpiformat - the encoding format; ignoredjava.io.IOException - if an encoding error occursprotected java.security.spec.AlgorithmParameterSpec engineGetParameterSpec(java.lang.Class paramSpec)
throws java.security.spec.InvalidParameterSpecException
paramSpec
identifies the specification class in which the parameters should be returned, which might be
iaik.pkcs.pkcs11.provider.ciphers.PKCS11GCMParameterSpec (preferred choice),
iaik.security.cipher.GCMParameterSpec or javax.crypto.spec.GCMParameterSpec.
Since GCM support has not been been introduced before Java7 javax.crypto.spec.GCMParameterSpec
can only be used with Java 7 or later.engineGetParameterSpec in class java.security.AlgorithmParametersSpiparamSpec - the specification class in which the parameters should be returned
- has to be class iaik.pkcs.pkcs11.provider.ciphers.PKCS11GCMParameterSpec (preferred choice),
iaik.security.cipher.GCMParameterSpec
or (Java7 or later) class javax.crypto.spec.GCMParameterSpecjava.security.spec.InvalidParameterSpecException - if the requested parameter specification is inappropriate
for this parameter object.protected void engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
throws java.security.spec.InvalidParameterSpecException
paramSpec.
paramSpec might specify class iaik.pkcs.pkcs11.provider.ciphers.PKCS11GCMParameterSpec (preferred choice),
iaik.security.cipher.GCMParameterSpec or class javax.crypto.spec.GCMParameterSpec.
Since GCM support has not been been introduced before Java7 javax.crypto.spec.GCMParameterSpec
can only be used with Java 7 or later.engineInit in class java.security.AlgorithmParametersSpiparamSpec - the parameter specification - iaik.pkcs.pkcs11.provider.ciphers.PKCS11GCMParameterSpec (preferred choice),
iaik.security.cipher.GCMParameterSpec or javax.crypto.spec.GCMParameterSpecjava.security.spec.InvalidParameterSpecException - if the given parameter specification is
inappropriate for the initialization of this parameter object.protected void engineInit(byte[] params)
throws java.io.IOException
engineInit in class java.security.AlgorithmParametersSpiparams - the DER encoded byte arrayjava.io.IOException - if an error occurs when decoding the given byte array or
the derived parameter values are invalidprotected void engineInit(byte[] params,
java.lang.String format)
throws java.io.IOException
engineInit(params) for initializing this GCMParameters
object from the given DER encoded byte array, regardless of what is specified
in the format string.
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.lang.String engineToString()
engineToString in class java.security.AlgorithmParametersSpiIAIK PKCS#11 Provider 1.10.0
(c) 2002 IAIK, (c) 2003, 2026 SIC