public class RSAOaepParameters extends PKCS1AlgorithmParameters
PKCS#1v2.1 defines the following parameters for the OAEP signature scheme:
RSASES-OAEP-params :: = SEQUENCE {
hashAlgorithm [0] HashAlgorithm DEFAULT sha1,
maskGenerationAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1,
pSourceAlgorithm [2] PSourceAlgorithm DEFAULT pSpecifiedEmpty,
}
HashAlgorithm ::= Algorithmidentifier { {OAEP-PSSDigestAlgorithms} }
MaskGenAlgorithm ::= AlgorithmIdentifier { {PKCS1MGFAlgorithms} }
PSourceAlgorithm ::= AlgorithmIdentifier { {PKCS1PSourceAlgorithms} }
By default OAEP uses SHA-1 as hash function, MGF1 (with SHA-1 as hash
function parameter) as mask generation algorithm, and id-pSpecified as
PSourceAlgorithm (with an empty OCTET STRING as parameter).
RSAOaepParameters can be generated provider independently by calling one of
the AlgorithmParameters.getInstance methods. Subsequently the
new AlgorithmParameters object must be initialized with a proper RSA-OAEP
parameter specification or a DER encoded byte array, e.g.:
RSAOaepParameterSpec oaepParamSpec = ...;
AlgorithmParameters params = AlgorithmParameters.getInstance("RSAES-OAEP", "IAIK");
params.init(oaepParamSpec);
respectively:
byte[] encodedOaepParams = ...;
AlgorithmParameters params = AlgorithmParameters.getInstance("RSAES-OAEP", "IAIK");
params.init(encodedOaepParams);
For obtaining OAEP parameters in transparent representation from an opaque
RSAOaepParameters object, the getParameterSpec method can be
used; for obtaining the parameters as DER encoded ASN.1 object, use method
getEncoded:
RSAOaepParameterSpec oaepParamSpec = (RSAOaepParameterSpec) params
.getParameterSpec(RSAOaepParameterSpec.class);
respectively
byte[] encodedOaepParams = params.getEncoded();
RSAOaepParameterSpec,
AlgorithmParameters| Constructor and Description |
|---|
RSAOaepParameters()
The default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
decode(ASN1Object asn1Params)
Initializes this RSAOaepParameters object from the given ASN1Object.
|
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 RSA-OAEP parameters as transparent parameter specification of
the given class type.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes this RSAOaepParameters from the given RSAOaepParameterSpec.
|
protected void |
engineInit(byte[] params)
Initializes this RSAOaepParameters 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.
|
static boolean |
getEncodeDefaultValues()
This method shows if parameter values should be encoded even if they have
the default values; e.g.
|
static void |
setEncodeDefaultValues(boolean encode)
With this method, the application can define that parameter values should
be encoded even if they have the default values; e.g.
|
ASN1Object |
toASN1Object()
Gets an ASN.1 representation of this RSA OAEP parameters.
|
public RSAOaepParameters()
RSAOaepParameters object. Applications shall use one of the
AlgorithmParameters.getInstance factory methods for obtaining
RSAOaepParameters.public static void setEncodeDefaultValues(boolean encode)
Note that the settings given by the RSAOaepParameterSpec have
higher priority.
Note that only a value of false results in a fully correct DER
encoding, because DER encoding required default values to be omitted.
encode - true to encode default values, false to
omit default values in the encoding.RSAOaepParameterSpec.setEncodeDefaultValues(Boolean),
RSAOaepParameterSpec.getEncodeDefaultValues()public static boolean getEncodeDefaultValues()
Note that the settings given by the RSAOaepParameterSpec have
higher priority.
Per default, this is false.
Note that only a value of false results in a fully correct DER
encoding, because DER encoding required default values to be omitted.
true if default values are encoded, false
if default values are omitted.RSAOaepParameterSpec.setEncodeDefaultValues(Boolean),
RSAOaepParameterSpec.getEncodeDefaultValues()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. 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 occurspublic ASN1Object toASN1Object()
protected 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 (RSAOaepParameterSpec)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.AlgorithmParametersSpiparamSpec - the parameter specification, which has to be a
RSAOaepParameterSpecjava.security.spec.InvalidParameterSpecException - if the given parameter specification is not a or is an invalid
RSAOaepParameterSpecprotected 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 arraypublic void decode(ASN1Object asn1Params) throws CodingException
asn1Params - the OAEP parameters in ASN.1 representationCodingException - if an error occurs when parsing the parametersprotected void engineInit(byte[] params,
java.lang.String format)
throws java.io.IOException
engineInit(params) for initializing this
RSAOaepParameters 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.AlgorithmParametersSpi