public abstract class SignedDataStreamDemo extends PKCS11Demo
| Modifier and Type | Field and Description |
|---|---|
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.
|
iaikPkcs11Provider_, iaikSoftwareProvider_, moduleName_, tokenKeyStore_, userPin_| Modifier | Constructor and Description |
|---|---|
protected |
SignedDataStreamDemo()
Creates a SignedDataStreamDemo object that has to be explicitly
initialized with a module name. |
| Modifier and Type | Method and Description |
|---|---|
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_
. |
getKeyStore, initprotected java.security.PrivateKey signerKey_
protected java.security.cert.X509Certificate signerCertificate_
protected SignedDataStreamDemo()
initialized with a module name.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 algorithmjava.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 signerpublic 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.