iaik.pkcs.pkcs1
Class RSAOaepParameterSpec

java.lang.Object
  |
  +--iaik.pkcs.pkcs1.PKCS1AlgorithmParameterSpec
        |
        +--iaik.pkcs.pkcs1.RSAOaepPSourceParameterSpec
              |
              +--iaik.pkcs.pkcs1.RSAOaepParameterSpec
All Implemented Interfaces:
AlgorithmParameterSpec, Cloneable

public class RSAOaepParameterSpec
extends RSAOaepPSourceParameterSpec
implements Cloneable

Algorithm parameter specification for the PKCS#1 RSAES-OAEP encryption scheme.

PKCS#1v2.1 defines the following parameters for the OAEP encryption scheme:

 RSASES-OAEP-params :: = SEQUENCE {
      hashAlgorithm            [0] HashAlgorithm     DEFAULT sha1,
      maskGenerationAlgorithm  [1] MaskGenAlgorithm  DEFAULT mgf1SHA1,
      pSourceAlgorithm         [2] PSourceAlgorithm  DEFAULT pSpecifiedEmpty,
 }

 HashAlgorithm ::= AlgorithmIdentifer { {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).

Hash algorithm, mask generation function, and PSourceAlgorithm have to be supplied when creating a creating a RSAOaepParameterSpec object, e.g.:

 // hash, mgf and pSource algorithm ids
 AlgorithmID hashID = (AlgorithmID)AlgorithmID.sha1.clone();
 AlgorithmID mgfID = (AlgorithmID)AlgorithmID.mgf1.clone();
 mgfID.setParameter(hashID.toASN1Object());
 AlgorithmID pSourceID = (AlgorithmID)AlgorithmID.pSpecified.clone();
 pSourceID.setParameter(new OCTET_STRING());
 // hash and mgf engines
 MessageDigest hashEngine = hashID.getMessageDigestInstance();
 MaskGenerationAlgorithm mgfEngine = mgfID.getMaskGenerationAlgorithmInstance();
 MGF1ParameterSpec mgf1ParamSpec = new MGF1ParameterSpec(hashID);
 mgf1ParamSpec.setHashEngine(hashEngine);
 mgfEngine.setParameters(mgf1ParamSpec);
 // create the RSAOaepParameterSpec
 RSAOaepParameterSpec oaepParamSpec = new RSAOaepParameterSpec(hashID, mgfID, pSourceID);
 // set engines
 oaepParamSpec.setHashEngine(hashEngine);
 oaepParamSpec.setMGFEngine(mgfEngine);
 

Version:
File Revision 9
See Also:
RSAOaepParameters, MaskGenerationAlgorithm, MGF1, MGF1ParameterSpec, RSACipher, AlgorithmID, OCTET_STRING

Field Summary
static AlgorithmID DEFAULT_HASH_ALGORITHM
          Default hash algorithm (SHA-1).
static AlgorithmID DEFAULT_MASK_GEN_ALGORITHM
          Default mask generation algorithm (MGF1 with SHA1 as hash algorithm)
 
Fields inherited from class iaik.pkcs.pkcs1.RSAOaepPSourceParameterSpec
DEFAULT_PSOURCE_ALGORITHM, pSourceAlgorithm_
 
Constructor Summary
RSAOaepParameterSpec()
          Creates default RSAES-OAEP parameters.
RSAOaepParameterSpec(AlgorithmID hashAlgorithm, AlgorithmID maskGenAlgorithm, AlgorithmID pSourceAlgorithm)
          Creates a RSAOaepParameterSpec for the given hash algorithm, mask generation function, and pSource algorithm.
 
Method Summary
 Object clone()
          Returns a clone of this Object.
 AlgorithmID getHashAlgorithm()
          Returns the hash algorihtm.
 MessageDigest getHashEngine()
          Gets the JCA MessageDigest engine used for data hashing.
 AlgorithmID getMaskGenAlgorithm()
          Gets the mask generation algorithm.
 MaskGenerationAlgorithm getMGFEngine()
          Gets the MaskGenerationAlgorithm engine.
 void setHashEngine(MessageDigest hashEngine)
          Sets the JCA MessageDigest engine to be used for data hashing.
 void setMGFEngine(MaskGenerationAlgorithm mgfEngine)
          Sets the MaskGenerationAlgorithm engine to be used.
 String toString()
          Returns a string representation of this RSAOaepParameterSpec.
 
Methods inherited from class iaik.pkcs.pkcs1.RSAOaepPSourceParameterSpec
getDefault, getLabel, getPSourceAlgorithm, setLabel
 
Methods inherited from class iaik.pkcs.pkcs1.PKCS1AlgorithmParameterSpec
getSecureRandom, setSecureRandom
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_HASH_ALGORITHM

public static final AlgorithmID DEFAULT_HASH_ALGORITHM
Default hash algorithm (SHA-1).

DEFAULT_MASK_GEN_ALGORITHM

public static final AlgorithmID DEFAULT_MASK_GEN_ALGORITHM
Default mask generation algorithm (MGF1 with SHA1 as hash algorithm)
Constructor Detail

RSAOaepParameterSpec

public RSAOaepParameterSpec()
Creates default RSAES-OAEP parameters.

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), see (see PKCS#1v2.1:

 RSASES-OAEP-params :: = SEQUENCE {
      hashAlgorithm            [0] HashAlgorithm     DEFAULT sha1,
      maskGenerationAlgorithm  [1] MaskGenAlgorithm  DEFAULT mgf1SHA1,
      pSourceAlgorithm         [2] PSourceAlgorithm  DEFAULT pSpecifiedEmpty,
 }

 HashAlgorithm ::= AlgorithmIdentifer { {OAEP-PSSDigestAlgorithms} }

 MaskGenAlgorithm ::= AlgorithmIdentifier { {PKCS1MGFAlgorithms} }

 PSourceAlgorithm ::= AlgorithmIdentifier { {PKCS1PSourceAlgorithms} }
 

RSAOaepParameterSpec

public RSAOaepParameterSpec(AlgorithmID hashAlgorithm,
                            AlgorithmID maskGenAlgorithm,
                            AlgorithmID pSourceAlgorithm)
Creates a RSAOaepParameterSpec for the given hash algorithm, mask generation function, and pSource algorithm.
Parameters:
hashAlgorithm - the hash algorithm to be used
Throws:
IllegalArgumentException - if hashAlgorithm or maskGenAlgorithm or pSourceAlgorithm are null
Method Detail

getHashAlgorithm

public AlgorithmID getHashAlgorithm()
Returns the hash algorihtm.
Returns:
the hash algorithm

getMaskGenAlgorithm

public AlgorithmID getMaskGenAlgorithm()
Gets the mask generation algorithm.
Returns:
the mask generation algorithm

setHashEngine

public void setHashEngine(MessageDigest hashEngine)
Sets the JCA MessageDigest engine to be used for data hashing.

This method may be used to set a JCA MessageDigest engine to be used for doing the any required hashing operations. If not set by this method, getHashEngine will try to create a MessageDigest engine from the hash algorithm id.

Parameters:
hashEngine - the JCA MessageDigest engine to be used

getHashEngine

public MessageDigest getHashEngine()
                            throws NoSuchAlgorithmException
Gets the JCA MessageDigest engine used for data hashing.

If method setHashEngine has been used to set a MessageDigest engine, this engine is returned; otherwise it is tried to create a MessageDigest engine from the hash algorithm id.

Returns:
the MessageDigest engine to be used

setMGFEngine

public void setMGFEngine(MaskGenerationAlgorithm mgfEngine)
Sets the MaskGenerationAlgorithm engine to be used.

This method may be used to set a MaskGenerationAlgorithm engine. If not set by this method, getMGFEngine will try to create a MaskGenerationAlgorithm engine from the mask generation algorithm id.

Parameters:
mgfEngine - the MaskGenerationAlgorithm engine to be used

getMGFEngine

public MaskGenerationAlgorithm getMGFEngine()
                                     throws NoSuchAlgorithmException
Gets the MaskGenerationAlgorithm engine.

If method setMGFEngine has been used to set a MGF engine, this engine is returned; otherwise it is tried to create a MGF engine from the Mask generation algorithm id.

Returns:
the MGF engine to be used

clone

public Object clone()
Returns a clone of this Object.
Overrides:
clone in class Object
Returns:
a clone of this Object

toString

public String toString()
Returns a string representation of this RSAOaepParameterSpec.
Overrides:
toString in class RSAOaepPSourceParameterSpec
Returns:
a string representation

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK