public class EdDSASignedDataDemo extends java.lang.Object
Any keys/certificates required for this demo are read from a keystore
file "cmsecc.keystore" located in your current working directory. If
the keystore file does not exist you can create it by running the
SetupCMSEccKeyStore
program.
Additionally to iaik_cms.jar you also must have
iaik_jce_(full).jar (IAIK-JCE,
https://sic.tech/products/core-crypto-toolkits/jca-jce/),
and iaik_eccelarate.jar (IAIK-ECCelerateTM,
https://sic.tech/products/core-crypto-toolkits/eccelerate/)
in your classpath.
| Constructor and Description |
|---|
EdDSASignedDataDemo()
Default Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
createSignedData(byte[] message,
int mode,
iaik.asn1.structures.AlgorithmID hashAlgorithm,
iaik.asn1.structures.AlgorithmID signatureAlgorithm,
java.security.PrivateKey signerKey,
iaik.x509.X509Certificate[] certificates)
Creates an EdDSA signed CMS
SignedData object and wraps it by a CMS
ContentInfo object. |
byte[] |
createSignedDataStream(byte[] message,
int mode,
iaik.asn1.structures.AlgorithmID hashAlgorithm,
iaik.asn1.structures.AlgorithmID signatureAlgorithm,
java.security.PrivateKey signerKey,
iaik.x509.X509Certificate[] certificates)
Creates an EdDSA signed CMS
SignedDataStream object and wraps it by a
CMS ContentInfoStream. |
byte[] |
getSignedData(byte[] signedData,
byte[] message,
iaik.x509.X509Certificate[] certificates)
Parses a CMS
ContentInfo holding a SignedData
object and verifies the signature. |
byte[] |
getSignedDataStream(byte[] signedData,
byte[] message,
iaik.x509.X509Certificate[] certificates)
Parses a CMS
ContentInfo object holding a SignedData
object and verifies the signature. |
static void |
main(java.lang.String[] argv)
Starts the demo.
|
void |
runDemo(byte[] message,
iaik.asn1.structures.AlgorithmID hashAlgorithm,
iaik.asn1.structures.AlgorithmID signatureAlgorithm,
iaik.utils.KeyAndCertificate signerKeyAndCert)
Runs the signing - verifying demo.
|
void |
start()
Tests the CMS SignedData implementation with the ECDSA signature
algorithm and several hash algorithms.
|
public EdDSASignedDataDemo() throws java.lang.Exception
java.lang.Exceptionpublic byte[] createSignedDataStream(byte[] message, int mode, iaik.asn1.structures.AlgorithmID hashAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] certificates) throws iaik.cms.CMSException, java.io.IOException
SignedDataStream object and wraps it by a
CMS ContentInfoStream.message - the message to be signed, as byte representationmode - the transmission mode, either IMPLICIT or EXPLICIThashAlgorithm - the hash algorithm to be usedsignatureAlgorithm - the signature algorithm to be usedsignerKey - the private key of the signercertificates - the certificate chain of the signerContentInfo object just creatediaik.cms.CMSException - if the SignedData, ContentInfo
object cannot be createdjava.io.IOException - if an I/O related error occurspublic byte[] getSignedDataStream(byte[] signedData, byte[] message, iaik.x509.X509Certificate[] certificates) throws iaik.cms.CMSException, java.io.IOException
ContentInfo object holding a SignedData
object and verifies the signature.signedData - the ContentInfo holding the SignedData
object as BER encoded byte arraymessage - the the message which was transmitted out-of-band (explicit signed)certificates - the certificate of the signer (used for alternative signature verification)iaik.cms.CMSException - if any signature does not verifyjava.io.IOException - if an I/O related error occurspublic byte[] createSignedData(byte[] message, int mode, iaik.asn1.structures.AlgorithmID hashAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] certificates) throws iaik.cms.CMSException, java.io.IOException
SignedData object and wraps it by a CMS
ContentInfo object.
message - the message to be signed, as byte representationmode - the mode, either SignedData.IMPLICIT or SignedData.EXPLICIThashAlgorithm - the hash algorithm to be usedsignatureAlgorithm - the signature algorithm to be usedsignerKey - the private key of the signercertificates - the certificate chain of the signerSignedData-ContentInfo objectiaik.cms.CMSException - if the SignedData-ContentInfo object cannot
be createdjava.io.IOException - if an I/O related error occurspublic byte[] getSignedData(byte[] signedData, byte[] message, iaik.x509.X509Certificate[] certificates) throws iaik.cms.CMSException, java.io.IOException
ContentInfo holding a SignedData
object and verifies the signature.signedData - the ContentInfo holding the SignedData
object as DER encoded byte arraymessage - the message which was transmitted out-of-band (explicit signed)certificates - the certificate of the signer (used for alternative signature verification)iaik.cms.CMSException - if any signature does not verifyjava.io.IOException - if an I/O related error occurspublic void runDemo(byte[] message, iaik.asn1.structures.AlgorithmID hashAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, iaik.utils.KeyAndCertificate signerKeyAndCert) throws java.lang.Exception
message - the message to be signedhashAlgorithm - the hash algorithm to be usedsignatureAlgorithm - the signature algorithm to be usedsignerKeyAndCert - private key and certificate chain of the signerjava.lang.Exceptionpublic void start() throws java.lang.Exception
java.lang.Exceptionpublic static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception - if an error occurs