public class PBMAC1Parameters
extends java.security.AlgorithmParametersSpi
PBMAC1 uses a message authentication scheme like HMAC for calculating the mac value with a secret key derived from a password by using a key derivation function like PBKDF2. The message authentication scheme and key derivation function to be used have to be specified by PBMAC1 parameters (see RFC 8018):
PBMAC1 parameters specify message authentication scheme and key derivation function to be used (see RFC 8018):
PBMAC1-params ::= SEQUENCE { keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}}, encryptionScheme AlgorithmIdentifier {{PBMAC1-Encs}} } PBMAC1-KDFs ALGORITHM-IDENTIFIER ::= { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ... } PBMAC1-Encs ALGORITHM-IDENTIFIER ::= { ... }PBMAC1Parameters can be generated by calling one of the
AlgorithmParameters.getInstance
methods. Subsequently
the new AlgorithmParameters object must be initialized with a proper PBMAC1 parameter
specification or a DER encoded byte array, e.g.:
PBMAC1ParameterSpec paramSpec = ...; AlgorithmParameters params = AlgorithmParameters.getInstance("PBMAC1", "IAIK"); params.init(paramSpec);respectively:
byte[] encodedParams = ...; AlgorithmParameters params = AlgorithmParameters.getInstance("PBMAC1", "IAIK"); params.init(encodedParams);
For obtaining PBMAC1 parameters in transparent representation from an opaque
PBMAC1Parameters object, the getParameterSpec
method can be used;
for obtaining the parameters as DER encoded ASN.1 object, use method
getEncoded
:
PBMAC1ParameterSpec paramSpec = (PBMAC1ParameterSpec) params .getParameterSpec(PBMAC1ParameterSpec.class);respectively
byte[] encodedParams = params.getEncoded();
PBMAC1ParameterSpec
,
AlgorithmParameters
Constructor and Description |
---|
PBMAC1Parameters()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected byte[] |
engineGetEncoded()
Returns the (DER) encoded PBMAC1 parameters.
|
protected byte[] |
engineGetEncoded(java.lang.String format)
Returns the (DER) encoded PBMAC1 parameters.
|
protected java.security.spec.AlgorithmParameterSpec |
engineGetParameterSpec(java.lang.Class paramSpec)
Returns the PBMAC1 parameters as transparent PBMAC1 parameter specification of the
given class type.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes this PBMAC1Parameters with the given PBMAC1ParameterSpec.
|
protected void |
engineInit(byte[] params)
Initializes this PBMAC1Parameters 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 the parameters.
|
public PBMAC1Parameters()
PBMAC1Parameters
object.
Applications shall use one of the AlgorithmParameters.getInstance("PBMAC1", "IAIK")
factory methods for obtaining PBMAC1Parameters.protected 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
Format is ignored. Only DER encoding is supported at this time. This method
only calls engineGetEncoded()
for returning the PBMAC1 parameters as DER encoded byte array, 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.security.spec.AlgorithmParameterSpec engineGetParameterSpec(java.lang.Class paramSpec) throws java.security.spec.InvalidParameterSpecException
engineGetParameterSpec
in class java.security.AlgorithmParametersSpi
paramSpec
- the desired parameter specification class, must be PBMAC1ParameterSpec.class
java.security.spec.InvalidParameterSpecException
- if the parameters cannot be converted to
the desired parameter specificationprotected void engineInit(java.security.spec.AlgorithmParameterSpec paramSpec) throws java.security.spec.InvalidParameterSpecException
engineInit
in class java.security.AlgorithmParametersSpi
paramSpec
- the parameter specification, which has to be a PBMAC1ParameterSpecjava.security.spec.InvalidParameterSpecException
- if the given parameter specification
is not a PBMAC1ParameterSpecprotected void engineInit(byte[] params) throws java.io.IOException
engineInit
in class java.security.AlgorithmParametersSpi
params
- the DER encoded PBMAC1 parametersjava.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 PBMAC1Parameters 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 PBMAC1 parametersformat
- 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.AlgorithmParametersSpi