|
IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdemo.cms.pkcs11.PKCS11Demo
demo.cms.pkcs11.SignedDataStreamDemo
public abstract class SignedDataStreamDemo
Base class of SignedDataStream demos using PKCS#11 for accessing the signer key on a smart card.
Field Summary | |
---|---|
protected java.security.cert.X509Certificate |
signerCertificate_
This is the certificate used for verifying the signature. |
protected java.security.PrivateKey |
signerKey_
The private key of the signer. |
Fields inherited from class demo.cms.pkcs11.PKCS11Demo |
---|
iaikPkcs11Provider_, iaikSoftwareProvider_, moduleName_, tokenKeyStore_, userPin_ |
Constructor Summary | |
---|---|
protected |
SignedDataStreamDemo()
Creates a SignedDataStreamDemo object that has to be explicitly initialized with a module name. |
Method Summary | |
---|---|
protected iaik.cms.SignerInfo |
createSignerInfo(iaik.x509.X509Certificate signerCertificate)
This method creates a SignerInfo for the given signer certificate. |
protected void |
getSignatureKey()
This method gets the key stores of all inserted (compatible) smart cards and simply takes the first key-entry. |
protected void |
getSignatureKey(java.lang.String algorithm)
This method gets the key stores of all inserted (compatible) smart cards and simply takes the first key-entry. |
void |
init(java.lang.String[] args)
This method starts the demo based on the given command line arguments. |
byte[] |
sign(byte[] data,
boolean implicit)
This method signs the data in the byte array DATA with
signatureKey_ . |
void |
start(boolean implicit)
Starts the demo. |
byte[] |
verify(byte[] encodedSignedData,
byte[] contentData)
This method verifies the signature stored in signatureKey_
. |
Methods inherited from class demo.cms.pkcs11.PKCS11Demo |
---|
getKeyStore, init |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.security.PrivateKey signerKey_
protected java.security.cert.X509Certificate signerCertificate_
Constructor Detail |
---|
protected SignedDataStreamDemo()
initialized
with a module name.
Method Detail |
---|
protected void getSignatureKey() throws java.security.GeneralSecurityException, java.io.IOException
signerKey_
and signerCertificate_
.
java.security.GeneralSecurityException
- If anything with the provider fails.
java.io.IOException
- If loading the key store fails.protected void getSignatureKey(java.lang.String algorithm) throws java.security.GeneralSecurityException, java.io.IOException
signerKey_
and signerCertificate_
.
algorithm
is not null
only those keys
are considered that match the given algorithm.
algorithm
- the key algorithm; maybe null
to take
the first signing key regardless of its algorithm
java.security.GeneralSecurityException
- If anything with the provider fails.
java.io.IOException
- If loading the key store fails.protected iaik.cms.SignerInfo createSignerInfo(iaik.x509.X509Certificate signerCertificate)
signerCertificate
- the certificate of the signer
public byte[] sign(byte[] data, boolean implicit) throws java.security.GeneralSecurityException, java.io.IOException, iaik.cms.CMSException
DATA
with
signatureKey_
. Normally the data would be read from file.
The created signature is stored in signature_
.
data
- the data to be signedimplicit
- whether to include the data (implicit mode)
or to not include it (explicit mode)
java.security.GeneralSecurityException
- If anything with the provider fails.
java.io.IOException
- If the data file could not be found or writing to it failed.
iaik.cms.CMSException
- If an error occurs when creating/encoding the SignedDatapublic byte[] verify(byte[] encodedSignedData, byte[] contentData) throws java.security.GeneralSecurityException, iaik.cms.CMSException, java.io.IOException, java.security.SignatureException
signatureKey_
. The verification key used is verificationKey_
.
The implementation for the signature algorithm is taken from an
other provider. Here IAIK is used, IAIK is pure software.
encodedSignedData
- the encoded SignedData objectcontentData
- the contentData (in explicit mode required for signature verification)
java.security.GeneralSecurityException
- If anything with the provider fails.
java.io.IOException
- If reading the CMS file fails.
iaik.cms.CMSException
- If handling the CMS structure fails.
java.security.SignatureException
- If the signature verification failspublic void start(boolean implicit)
implicit
- whether the implicit or explicit mode is used (data included in signature or not)public void init(java.lang.String[] args)
args
- These are the command line arguments.
|
IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
![]() |
v6.1 (c) 2002 IAIK, (c) 2003 - 2025 SIC |
![]() |