|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.security.SignatureSpi | +--java.security.Signature | +--iaik.security.rsa.RSAPkcs1Signature | +--iaik.security.rsa.RSASignature | +--iaik.security.rsa.RawRSAPkcs1v15Signature
This class represents a "raw" implemention of the RSA PKCS#1v1.5 digital signature algorithm (RSASSA-PKCS1-v1_5) where the hash on the data to be signed has to be calculated by the application.
In contrast to the RawRSASignature
engine class
where the application has to do both hash calculation and DigestInfo wrapping, this class
only expects that the hash value is supplied to one of its update methods and does the
DigestInfo wrapping/unwrapping itself. Since building the DigestInfo requires the knowledge
of the hash algorithm in use, the calling application has to supply the corresponding
algorithm id as RSASSAPkcs1v15ParameterSpec
:
AlgorithmID hashAlgorithm = AlgorithmID.sha1; RSASSAPkcs1v15ParameterSpec params = new RSASSAPkcs1v15ParameterSpec(hashAlgorithm);
Generally an application wishing to sign some message or to verify some signature, generally
has to perform four steps (in the following example, HASH
has to be
replaced by the name of the desired hash algorithm):
getInstance
method, e.g.:
Signature rawRsaSignatureEngine = Signature.getInstance("RSAPkcs15", "IAIK");
rawRsaSignatureEngine.initSign(rsaPrivateKey);
rawRsaSignatureEngine.initVerify(rsaPublicKey);
AlgorithmID hashAlgorithm = AlgorithmID.HASH; // e.g. AlgorithmID.sha1 RSASSAPkcs1v15ParameterSpec params = new RSASSAPkcs1v15ParameterSpec(hashAlgorithm); rawRsaSignatureEngine.setParameter(null, params);
sign
method returning the signature as byte array.
Otherwise, if the Signature object has been initialized for verifying, first the
prepared hash to be verified is supplied to the Signature object, and subsequently the
signature is verified by calling the verify
method, supplied with
the byte array holding the corresponding signature value:
rawRsaSignatureEngine.update(preparedHash); byte[] signature = rawRsaSignatureEngine.sign();
rawRsaSignatureEngine.update(preparedHash); System.out.println("Signature " + (rawRsaSignatureEngine.verify(signature) ? "correct!" : "incorrect!"));
update
method; no check is
performed if the supplied hash value corresponds to the hash algorithm
in use (e.g. has the correct length).
Signature
Fields inherited from class iaik.security.rsa.RSASignature |
hash |
Fields inherited from class java.security.Signature |
SIGN, state, UNINITIALIZED, VERIFY |
Fields inherited from class java.security.SignatureSpi |
appRandom |
Constructor Summary | |
RawRSAPkcs1v15Signature()
Default constructor. |
Method Summary | |
protected Object |
engineGetParameter(String param)
Returns the hash algorithm parameter used by this PKCS#1.5 signature engine. |
protected AlgorithmParameters |
engineGetParameters()
Returns the hash algorithm parameter used by this PKCS#1.5 signature engine. |
protected void |
engineSetParameter(AlgorithmParameterSpec params)
Sets the hash algorithm parameter to be used by this PKCS#1.5 signature engine. |
protected void |
engineSetParameter(String param,
Object value)
Sets the hash algorithm parameter to be used by this PKCS#1.5 signature engine. |
Methods inherited from class iaik.security.rsa.RSASignature |
engineInitSign, engineInitSign, engineInitVerify, engineSign, engineUpdate, engineUpdate, engineVerify |
Methods inherited from class java.security.Signature |
clone, getAlgorithm, getInstance, getInstance, getParameter, getProvider, initSign, initSign, initVerify, initVerify, setParameter, setParameter, sign, sign, toString, update, update, update, verify |
Methods inherited from class java.security.SignatureSpi |
engineSign |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RawRSAPkcs1v15Signature()
Applications use
for creating a Signature object.Signature.getInstance("RSAPkcs15");
Method Detail |
protected void engineSetParameter(String param, Object value) throws InvalidParameterException
RawRSASignature
engine class
where the application has to do both hash calculation and DigestInfo wrapping, this class
only expects that the hash value is supplied to one of its update methods and does the
DigestInfo wrapping/unwrapping itself. Since building the DigestInfo requires the knowledge
of the hash algorithm in use, the calling application has to supply the corresponding
algorithm id as RSASSAPkcs1v15ParameterSpec
:
AlgorithmID hashAlgorithm = AlgorithmID.sha1; RSASSAPkcs1v15ParameterSpec params = new RSASSAPkcs1v15ParameterSpec(hashAlgorithm); rawRsaSignatureEngine.setParameter(null, params);
engineSetParameter
in class iaik.security.rsa.RSAPkcs1Signature
param
- ignoredvalue
- the hash algorithm supplied as RSASSAPkcs1v15ParameterSpecInvalidParameterException
- if the hash algorithm is not supplied as
RSASSAPkcs1v15ParameterSpecprotected void engineSetParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
RawRSASignature
engine class
where the application has to do both hash calculation and DigestInfo wrapping, this class
only expects that the hash value is supplied to one of its update methods and does the
DigestInfo wrapping/unwrapping itself. Since building the DigestInfo requires the knowledge
of the hash algorithm in use, the calling application has to supply the corresponding
algorithm id as RSASSAPkcs1v15ParameterSpec
:
AlgorithmID hashAlgorithm = AlgorithmID.sha1; RSASSAPkcs1v15ParameterSpec params = new RSASSAPkcs1v15ParameterSpec(hashAlgorithm); rawRsaSignatureEngine.setParameter(null, params);
engineSetParameter
in class iaik.security.rsa.RSAPkcs1Signature
InvalidParameterException
- if the hash algorithm is not supplied as
RSASSAPkcs1v15ParameterSpecprotected Object engineGetParameter(String param) throws InvalidParameterException
engineGetParameter
in class iaik.security.rsa.RSAPkcs1Signature
InvalidParameterException
- should not occurprotected AlgorithmParameters engineGetParameters()
|
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 |