public class KDF2AlgorithmParameters
extends java.security.AlgorithmParametersSpi
This class represents the Algorithm Parameters of the KDF2.
According to ISO/IEC 18033-2 the encoding of the KDF2 is:
kdf2 ALGORITHM ::= { OID id-kdf-kdf2 PARMS HashFunction }
It is possible to generate KDF2Parameters provider independently by calling one of the
AlgorithmParameters.getInstance
methods. Subsequently the new
AlgorithmParameters object must be initialized with a proper KDF2 parameter
specification or a DER encoded byte array, e.g.:
KDF2ParameterSpec paramSpec = ...; AlgorithmParameters params = AlgorithmParameters.getInstance("KDF2", "IAIK"); params.init(paramSpec);respectively:
byte[] encodedParams = ...; AlgorithmParameters params = AlgorithmParameters.getInstance("KDF2", "IAIK"); params.init(encodedParams);
For obtaining KDF2 parameters in transparent representation from an opaque
KDF2Parameters object, a caller may use the getParameterSpec
method;
for obtaining the parameters as DER encoded ASN.1 object, use
getEncoded
:
KDF2ParameterSpec paramSpec = (KDF2ParameterSpec) params .getParameterSpec(KDF2ParameterSpec.class);respectively
byte[] encodedParams = params.getEncoded();
Constructor and Description |
---|
KDF2AlgorithmParameters() |
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 KDF2 parameters as transparent parameter specification of the
given class type.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes the Algorithm Parameters with an instance of KDF2ParameterSpec.
|
protected void |
engineInit(byte[] params)
Initializes this KDF2Parameters 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 String representation of this object.
|
protected void engineInit(java.security.spec.AlgorithmParameterSpec paramSpec) throws java.security.spec.InvalidParameterSpecException
Initializes the Algorithm Parameters with an instance of KDF2ParameterSpec. Note that KDF2ParameterSpec also holds information which the implementation will not encode. This includes the secret value, the key length, and any additional information stored in the spec class.
These information is lost after serialization.
engineInit
in class java.security.AlgorithmParametersSpi
paramSpec
- an instance of KDF2ParameterSpecjava.security.spec.InvalidParameterSpecException
- if the caller provides an inappropriate object for initializationprotected void engineInit(byte[] params) throws java.io.IOException
engineInit
in class java.security.AlgorithmParametersSpi
params
- ASN.1 encoding of KDF2 parametersjava.io.IOException
- if the provided byte array is inappropriate for decodingprotected void engineInit(byte[] params, java.lang.String format) throws java.io.IOException
Inits the parameters from an DER encoded byte array. Format is ignored.
Only calls {engineInit(params)
for initializing this
KDF2Parameters object from the given DER encoded byte array, regardless of
what is specified in the format
string.
engineInit
in class java.security.AlgorithmParametersSpi
params
- 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
Returns the KDF2 parameters as transparent parameter specification of the given class type.
engineGetParameterSpec
in class java.security.AlgorithmParametersSpi
paramSpec
- the desired parameter specification class (KDF2ParameterSpec)java.security.spec.InvalidParameterSpecException
- if the parameters cannot be converted to the desired parameter
specificationprotected byte[] engineGetEncoded() throws java.io.IOException
engineGetEncoded
in class java.security.AlgorithmParametersSpi
java.io.IOException
- if an encoding error occursprotected byte[] engineGetEncoded(java.lang.String format) throws java.io.IOException
Returns the parameters as a DER byte array.
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.AlgorithmParametersSpi
format
- the encoding format; ignoredjava.io.IOException
- if an encoding error occursprotected java.lang.String engineToString()
engineToString
in class java.security.AlgorithmParametersSpi