public class RSAOaepPSourceParameterSpec extends PKCS1AlgorithmParameterSpec
According PKCS#1v2.1
RSASES-OAEP
parameters consist
of hash algorithm id, mask generation function id, and PSourceAlgorithm:
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).
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding"); RSAOaepPSourceParameterSpec paramSpec = new RSAOaepPSourceParameterSpec((AlgorithmID)AlgorithmID.pSpecified.clone()); byte[] label = ...; paramSpec.setLabel(label); rsa.init(Cipher.ENCRYPT_MODE, publicKey, paramSpec); byte[] encrypted = rsa.doFinal(data);An OAEP padding scheme that implements the, for instance, "OAEPWithSHA1AndMGF1Padding" (in general: OAEPWith<digest>And<mgf>Padding) has to use SHA-1 as hash- and MGF1 as mask generation algorithm.
Modifier and Type | Field and Description |
---|---|
static AlgorithmID |
DEFAULT_PSOURCE_ALGORITHM
Default PSourceAlgorithm (id-pSpecified).
|
protected AlgorithmID |
pSourceAlgorithm_
PSourceAlgorithm.
|
Constructor and Description |
---|
RSAOaepPSourceParameterSpec()
Default constructor.
|
RSAOaepPSourceParameterSpec(AlgorithmID pSourceAlgorithm)
Creates a RSAOaepPSourceParameterSpec for the given PSourceAlgorithm.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Compares this RSAOaepPSourceParameterSpec object with the supplied object.
|
static RSAOaepPSourceParameterSpec |
getDefault()
Creates a RSAOaepPSourceParameterSpec with the default PSourceAlgorithm
id-pSpecified with empty OCTET STRING parameter.
|
byte[] |
getLabel()
Returns the value of the label parameter, if set.
|
AlgorithmID |
getPSourceAlgorithm()
Gets the PSourceAlgorithm.
|
int |
hashCode()
Gets a hash code for this object.
|
void |
setLabel(byte[] label)
Sets the value of the label parameter.
|
java.lang.String |
toString()
Gets a String representation of this RSAOaepPSourceParameterSpec.
|
getSecureRandom, setSecureRandom
public static final AlgorithmID DEFAULT_PSOURCE_ALGORITHM
protected AlgorithmID pSourceAlgorithm_
public RSAOaepPSourceParameterSpec()
public RSAOaepPSourceParameterSpec(AlgorithmID pSourceAlgorithm)
pSourceAlgorithm
- the PSourceAlgorithm to be used.java.lang.IllegalArgumentException
- pSourceAlgorithm is null or contains invalid parameterspublic static RSAOaepPSourceParameterSpec getDefault()
public AlgorithmID getPSourceAlgorithm()
public byte[] getLabel()
null
public void setLabel(byte[] label)
label
- the value of the label parameterjava.lang.NullPointerException
- if the PSourceAlgorithm is not setpublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to be comparedtrue
if the two objects are equal
false
otherwisepublic java.lang.String toString()
toString
in class java.lang.Object