IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.cms.pkcs7cms
Class PKCS7CMSSignedDataDemo

java.lang.Object
  extended by demo.cms.pkcs7cms.PKCS7CMSSignedDataDemo

public class PKCS7CMSSignedDataDemo
extends java.lang.Object

This class demonstrates the CMS SignedData implementation and checks it against the IAIK PKCS#7 library.


Constructor Summary
PKCS7CMSSignedDataDemo()
          Setup the demo certificate chains.
 
Method Summary
 iaik.asn1.ASN1Object createPKCS7SignedData(byte[] message, int mode)
          Creates a PKCS#7 SignedData object.
 byte[] createPKCS7SignedDataStream(byte[] message, int mode)
          Creates a PKCS#7 SignedData object.
 iaik.asn1.ASN1Object createSignedData(byte[] message, int mode)
          Creates a CMS SignedData object.
 byte[] createSignedDataStream(byte[] message, int mode)
          Creates a CMS SignedData object.
 byte[] getPKCS7SignedData(iaik.asn1.ASN1Object obj, byte[] message)
          Parses a PKCS#7 SignedData object and verifies the signatures for all participated signers.
 byte[] getPKCS7SignedDataStream(byte[] signedData, byte[] message)
          Parses a PKCS#7 SignedData object and verifies the signatures for all participated signers.
 byte[] getSignedData(iaik.asn1.ASN1Object obj, byte[] message)
          Parses a CMS or PKCS#7 SignedData object and verifies the signatures for all participated signers.
 byte[] getSignedDataStream(byte[] signedData, byte[] message)
          Parses a CMS or PKCS#7 SignedData object and verifies the signatures for all participated signers.
static void main(java.lang.String[] argv)
          Main method.
 void start()
          Tests the CMS SignedData implementation and checks it against the IAIK PKCS#7 library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PKCS7CMSSignedDataDemo

public PKCS7CMSSignedDataDemo()
                       throws java.io.IOException
Setup the demo certificate chains. Keys and certificate are retrieved from the demo KeyStore.

Throws:
java.io.IOException - if an file read error occurs
Method Detail

createSignedDataStream

public byte[] createSignedDataStream(byte[] message,
                                     int mode)
                              throws iaik.cms.CMSException,
                                     java.io.IOException
Creates a CMS SignedData object.

Parameters:
message - the message to be signed, as byte representation
mode - the transmission mode, either IMPLICIT or EXPLICIT
Returns:
the DER encoding of the SignedData object just created
Throws:
iaik.cms.CMSException - if the SignedData object cannot be created
java.io.IOException - if an I/O error occurs

createPKCS7SignedDataStream

public byte[] createPKCS7SignedDataStream(byte[] message,
                                          int mode)
                                   throws iaik.pkcs.PKCSException,
                                          java.io.IOException
Creates a PKCS#7 SignedData object.

Parameters:
message - the message to be signed, as byte representation
mode - the transmission mode, either IMPLICIT or EXPLICIT
Returns:
the DER encoding of the SignedData object just created
Throws:
iaik.pkcs.PKCSException - if the SignedData object cannot be created
java.io.IOException - if an I/O error occurs

getSignedDataStream

public byte[] getSignedDataStream(byte[] signedData,
                                  byte[] message)
                           throws iaik.cms.CMSException,
                                  java.io.IOException
Parses a CMS or PKCS#7 SignedData object and verifies the signatures for all participated signers.

Parameters:
signedData - SignedData object as DER encoded byte array
message - the the message which was transmitted out-of-band (explicit signed)
Returns:
the inherent message as byte array
Throws:
iaik.cms.CMSException - if any signature does not verify
java.io.IOException - if an I/O error occurs

getPKCS7SignedDataStream

public byte[] getPKCS7SignedDataStream(byte[] signedData,
                                       byte[] message)
                                throws iaik.pkcs.PKCSException,
                                       java.io.IOException
Parses a PKCS#7 SignedData object and verifies the signatures for all participated signers.

Parameters:
signedData - SignedData object as DER encoded byte array
message - the the message which was transmitted out-of-band (explicit signed)
Returns:
the inherent message as byte array
Throws:
iaik.pkcs.PKCSException - if any signature does not verify
java.io.IOException - if an I/O error occurs

createSignedData

public iaik.asn1.ASN1Object createSignedData(byte[] message,
                                             int mode)
                                      throws iaik.cms.CMSException,
                                             java.io.IOException
Creates a CMS SignedData object.

Parameters:
message - the message to be signed, as byte representation
mode - the mode, either SignedData.IMPLICIT or SignedData.EXPLICIT
Returns:
the SignedData object as ASN.1 object
Throws:
iaik.cms.CMSException - if the SignedData object cannot be created
java.io.IOException - if an I/O error occurs

createPKCS7SignedData

public iaik.asn1.ASN1Object createPKCS7SignedData(byte[] message,
                                                  int mode)
                                           throws iaik.pkcs.PKCSException,
                                                  java.io.IOException
Creates a PKCS#7 SignedData object.

Parameters:
message - the message to be signed, as byte representation
mode - the mode, either SignedData.IMPLICIT or SignedData.EXPLICIT
Returns:
the SignedData object as ASN.1 object
Throws:
iaik.pkcs.PKCSException - if the SignedData object cannot be created
java.io.IOException - if an I/O error occurs

getSignedData

public byte[] getSignedData(iaik.asn1.ASN1Object obj,
                            byte[] message)
                     throws iaik.cms.CMSException,
                            java.io.IOException
Parses a CMS or PKCS#7 SignedData object and verifies the signatures for all participated signers.

Parameters:
obj - SignedData object in ASN.1 representation
message - the the message which was transmitted out-of-band (explicit signed)
Returns:
the inherent message as byte array
Throws:
iaik.cms.CMSException - if any signature does not verify
java.io.IOException - if an I/O error occurs

getPKCS7SignedData

public byte[] getPKCS7SignedData(iaik.asn1.ASN1Object obj,
                                 byte[] message)
                          throws iaik.pkcs.PKCSException,
                                 java.io.IOException
Parses a PKCS#7 SignedData object and verifies the signatures for all participated signers.

Parameters:
obj - SignedData object in ASN.1 representation
message - the the message which was transmitted out-of-band (explicit signed)
Returns:
the inherent message as byte array
Throws:
iaik.pkcs.PKCSException - if any signature does not verify
java.io.IOException - if an I/O error occurs

start

public void start()
Tests the CMS SignedData implementation and checks it against the IAIK PKCS#7 library.


main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Main method.

Throws:
java.io.IOException - if an I/O error occurs when reading required keys and certificates from files
java.lang.Exception

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

v6.1
(c) 2002 IAIK, (c) 2003 - 2025 SIC