|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.cms.SecurityProvider iaik.cms.IaikProvider iaik.cms.IaikCCProvider
public class IaikCCProvider
This class implements a CMS SecurityProvider that may be used with the Common Criteria evaluated versions of the IAIK-JCE crypto toolkit. Because raw signature engines have not been subject of the CC evaluation, this SecurityProvider calculates and verifies RSA PKCS#1v1.5 signatures by using a Cipher engine for RSA en/decryption an doing the DigestInfo wrapping/unwrapping outside.
To install this security provider call:
SecurityProvider.setSecurityProvider(new IaikCCProvider());
SecurityProvider
,
IaikProvider
Field Summary |
---|
Fields inherited from class iaik.cms.IaikProvider |
---|
ALG_SIGNATURE_RAWRSA, ALG_SIGNATURE_RAWRSASSA_PKCS1_V15 |
Constructor Summary | |
---|---|
IaikCCProvider()
Default Constructor. |
|
IaikCCProvider(boolean installProvider)
Creates an IaikCCProvider. |
Method Summary | |
---|---|
byte[] |
calculateSignatureFromHash(AlgorithmID signatureAlgorithm,
AlgorithmID digestAlgorithm,
java.security.PrivateKey privateKey,
byte[] digest)
Calculates the signature value for a CMS SignerInfo over the given digest value with the given algorithm using the supplied private key. |
boolean |
verifySignatureFromHash(AlgorithmID signatureAlgorithm,
AlgorithmID digestAlgorithm,
java.security.PublicKey publicKey,
byte[] digest,
byte[] signatureValue)
Verifies the signature value of a CMS SignerInfo object with the given algorithm using the supplied public key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IaikCCProvider()
public IaikCCProvider(boolean installProvider)
installProvider
- whether to install the IAIK provider within
the JCA framework or to use it without
installing it within the JCE frameworkMethod Detail |
---|
public byte[] calculateSignatureFromHash(AlgorithmID signatureAlgorithm, AlgorithmID digestAlgorithm, java.security.PrivateKey privateKey, byte[] digest) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureException
Each SignerInfo
included in a CMS SignedData
object may calculate the signature value differently depending on the
presence of signed attributes:
SignerInfo
for
calculating the signature when no signed attributes are present. Since
the data to be signed may be of arbitrary size this method expects the
already hashed data to only calculate the signature value on it (for
instance, by doing the digest encrypting when using RSA for signing).
For that reason, when writing your own SecurityProvider and overriding this method, you will need some kind of RAW signature (respectively digest encryption) mechanism only expecting the already hashed data (e.g. a "RawDSA" signature engine when using DSA repectively a Cipher engine when using RSA).
If you want to override this method for use with smartcards, please be sure
that your smartcard is able to do the signature (respectively digest
encryption) operation only. However, if your smartcard requires to supply
the whole data for doing the hash calcualtion itself, you may ensure that
your SignerInfo
contains signed attributes
and override method calculateSignatureFromSignedAttributes
for calculating the signature over
the DER encoding of the signed attributes (thereby doing the hash
computation, too).
calculateSignatureFromHash
in class IaikProvider
signatureAlgorithm
- signatureAlgorithm the signature algorithm to be
used, e.g. rsaEncryption, DSAdigestAlgorithm
- the digest algorithm used for hash computation (e.g.
SHA-1, ..., SHA-512); may be necessary for some signature schemes (e.g.
to be included as a DigestInfo in a PKCS#1 RSA signature)privateKey
- the private key of the signer (i.e. the one supplied when
creating a SignerInfo
object; may be
some kind of "dummy" key when used for smartcardsdigest
- the digest value over which the signature shall be calculated
java.security.NoSuchAlgorithmException
- if any of the required algorithms is not supported
java.security.InvalidKeyException
- if the key is not valid
java.security.SignatureException
- if signature verification fails because of some crypto related errorpublic boolean verifySignatureFromHash(AlgorithmID signatureAlgorithm, AlgorithmID digestAlgorithm, java.security.PublicKey publicKey, byte[] digest, byte[] signatureValue) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureException
Each SignerInfo
included in a CMS SignedData
object may calculate the signature value differently depending on the
presence of signed attributes:
SignerInfo
for
verifying the signature when no signed attributes are present. Since
the data to be verified may be of arbitrary size this method expects the
already hashed data to only be verified against the signature value.
For that reason, when writing your own SecurityProvider and overriding this method, you will need some kind of RAW signature (respectively "encrypted digest decryption") mechanism only expecting the already hashed data (e.g. a "RawDSA" signature engine when using DSA repectively a Cipher engine when using RSA).
Although generally for public key operations smartcards may not be used,
when overriding this method for use with smartcards, please be sure
that your smartcard is able to do the signature verification operation only.
However, if your smartcard requires to supply the whole data for doing the
hash calcualtion itself, you may ensure that your SignerInfo
contains signed attributes and override method verifySignatureFromSignedAttributes
for verifying the signature calculated from the DER encoding of the signed
attributes (thereby doing the hash computation, too).
verifySignatureFromHash
in class IaikProvider
signatureAlgorithm
- signatureAlgorithm the signature algorithm to be
used for verification, e.g. rsaEncryption, DSAdigestAlgorithm
- the digest algorithm that has been used for hash
computation (e.g. SHA-1, ..., SHA-512); may be necessary for some signature
schemes (e.g. to be check against a DigestInfo in a PKCS#1 RSA signature)publicKey
- the public key of the signerdigest
- the digest value to be verifiedsignatureValue
- the signatureValue the signature value to be verified
true
if the signature is ok, false
if not
java.security.NoSuchAlgorithmException
- if any of the required algorithms is not supported
java.security.InvalidKeyException
- if the key is not valid
java.security.SignatureException
- if signature verification fails because
of some crypto related or parsing error
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |