|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--iaik.pkcs.pkcs1.MaskGenerationAlgorithmSpi
|
+--iaik.pkcs.pkcs1.MaskGenerationAlgorithm
|
+--iaik.pkcs.pkcs1.MGF1
This class implements the PKCS#1v2.1 mask generation algorithm MGF1 as used by by the RSASSA-PSS signature scheme and the RSAES-OAEP encryption scheme.
An application wishing to use some specific mask generation function, first tries to get an engine instance for the MGF1 mask generation algorithm:
MaskGenerationAlgorithm mgf = MaskGenerationAlgorithm.getInstance("MGF1", "IAIK");
After supplying the engine with parameters (if required), method has to be called to
"mask" the input data by XORing it with the mask generated from some seed by using the
mask generation algorithm. Since MGF1 is based on a hash algorithm the hash algorithm
may be supplied as MGF1ParameterSpec:
AlgorithmID hashAlgID = ...; MGF1ParameterSpec paramSpec = new MGF1ParameterSpec(hashAlgID); // optionally set the hash engine to be used: MessageDigest hashEngine = ...; paramSpec.setHashEngine(hashEngine); // set the parameters mgf.setParameters(paramSpec); // mask the data byte[] data = ...; byte[] dataOff = ...; byte[] seed = ...; int seedOff = ...; int seedLen = ...; int maskLen = ...; mgf.mask(seed, seedOff, seedLen, maskLen, data, dataOff);
MaskGenerationAlgorithm,
MGF1ParameterSpec,
MGF1Parameters| Field Summary | |
static ObjectID |
OID
The ASN.1 object identifier (1.2.840.113549.1.1.8) for the MGF1 mask generation algorithm. |
| Constructor Summary | |
MGF1()
Default constructor. |
|
MGF1(AlgorithmID hashAlgorithm,
MessageDigest hashEngine)
Creates a MGF1 object for given hash algorithm and hash engine. |
|
| Method Summary | |
Object |
clone()
Returns a clone of this Object. |
protected AlgorithmParameters |
engineGetParameters()
Returns the parameter (hash algorithm) used by this insatance of MGF1 object. |
protected void |
engineMask(byte[] mgfSeed,
int mgfSeedOff,
int mgfSeedLen,
int maskLen,
byte[] dst,
int dstOff)
Uses the mask generation function to generate maskLen bytes from the supplied seed mgfSeed[mgfSeedOff:mgfSeedLen] and XORs the result with dst[off:maskLen]. |
protected void |
engineReset()
Resets this engine to the state before engineMask has been called. |
protected void |
engineSetParameters(AlgorithmParameters params)
Sets the parameter (hash algorithm) for the MGF1 algorithm. |
protected void |
engineSetParameters(AlgorithmParameterSpec paramSpec)
Sets the parameter (hash algorithm) for the MGF1 algorithm. |
ObjectID |
getOID()
Gets the ASN.1 object identifier (1.2.840.113549.1.1.8) for the MGF1 mask generation function. |
| Methods inherited from class iaik.pkcs.pkcs1.MaskGenerationAlgorithm |
getAlgorithm, getInstance, getInstance, getParameters, mask, reset, setParameters, setParameters, toString |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final ObjectID OID
| Constructor Detail |
public MGF1()
public MGF1(AlgorithmID hashAlgorithm,
MessageDigest hashEngine)
hashAlgorithm - the hash algorithm to be usedhashEngine - the MessageDigest engine to be used| Method Detail |
protected void engineMask(byte[] mgfSeed,
int mgfSeedOff,
int mgfSeedLen,
int maskLen,
byte[] dst,
int dstOff)
engineMask in class MaskGenerationAlgorithmSpimgfSeed - the seed from which the mask is generatedmgfSeedOff - the offest indicating the start position within the seed arraymgfSeedLen - the actual number of seed bytesmaskLen - the number of required mask bytesdst - the destination array to which to XOR the mask resultdstOff - the offset indicating the start position within the destination array
protected void engineSetParameters(AlgorithmParameterSpec paramSpec)
throws InvalidAlgorithmParameterException
MGF1 algorithm.engineSetParameters in class MaskGenerationAlgorithmSpiparamSpec - the parameter (hash algorithm) to be usedInvalidAlgorithmParameterException - if the supplied parameter is not an instance of MGF1ParameterSpec
protected void engineSetParameters(AlgorithmParameters params)
throws InvalidAlgorithmParameterException
MGF1 algorithm.engineSetParameters in class MaskGenerationAlgorithmSpiparams - the parameter (hash algorithm) to be usedInvalidAlgorithmParameterException - if the supplied parameter is not an instance of MGF1ParameterSpecprotected AlgorithmParameters engineGetParameters()
MGF1 object.engineGetParameters in class MaskGenerationAlgorithmSpiMGF1ParameterSpecprotected void engineReset()
engineMask has been called.engineReset in class MaskGenerationAlgorithmSpipublic ObjectID getOID()
public Object clone()
clone in class MaskGenerationAlgorithmSpi
|
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). | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK