IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.smime.basic
Class CMSStreamDemo

java.lang.Object
  extended by demo.smime.basic.CMSStreamDemo

public class CMSStreamDemo
extends java.lang.Object

This class shows the usage of the SMimeSigned and SMimeEncrypted classes. These classes can be used to create/parse signed and/or encrypted CMS messages. This demo does not use the JavaMail API.

See Also:
SMimeSigned, SMimeEncrypted

Constructor Summary
CMSStreamDemo()
          Empty default constructor.
 
Method Summary
static void main(java.lang.String[] argv)
          The main method.
 void setupCertificates()
          Reads the required keys and certificates from the demo keystore.
 void start()
          Starts the demo.
 void testSMimeAuthEncrypted(iaik.asn1.structures.AlgorithmID contentEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int keyLength, int recipientIndex)
          Uses class SMimeAuthEncrypted to authenticated encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content.
 void testSMimeEncrypted(iaik.asn1.structures.AlgorithmID contentEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int keyLength, int recipientIndex)
          Uses class SMimeEncrypted to encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content.
 void testSMimeSigned(int mode)
          Uses class SMimeSigned to sign some data, encode it, and finally parses the encoding to verify the signature.
 void testSMimeSignedAndAuthEncrypted(iaik.asn1.structures.AlgorithmID contentEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int keyLength, int recipientIndex)
          Uses class SMimeSigned and class SMimeAuthEncrypted to sign and authenticated encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content and verify the signature.
 void testSMimeSignedAndEncrypted(iaik.asn1.structures.AlgorithmID contentEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int keyLength, int recipientIndex)
          Uses class SMimeSigned and class SMimeEncrypted to sign and encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content and verify the signature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMSStreamDemo

public CMSStreamDemo()
Empty default constructor.

Method Detail

setupCertificates

public void setupCertificates()
                       throws java.lang.Exception
Reads the required keys and certificates from the demo keystore.

Throws:
java.lang.Exception - if some error occurs when reading from the keystore

testSMimeEncrypted

public void testSMimeEncrypted(iaik.asn1.structures.AlgorithmID contentEA,
                               iaik.asn1.structures.AlgorithmID keyWrapAlg,
                               int keyLength,
                               int recipientIndex)
                        throws java.lang.Exception
Uses class SMimeEncrypted to encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content.

Parameters:
contentEA - the content encryption algorithm to be used
keyWrapAlg - the key wrap algorithm to be used for encrypting the temporary content encryption key
keyLength - the length of the content encryption key to be created and used
recipientIndex - the index into the recipientInfos field indicating for which recipient the message shall be decrypted
Throws:
java.lang.Exception - if some error occurs

testSMimeSigned

public void testSMimeSigned(int mode)
                     throws java.lang.Exception
Uses class SMimeSigned to sign some data, encode it, and finally parses the encoding to verify the signature.

Parameters:
mode - either implicit or explicit to indicate whether the content shall be included in the signature or transmitted out-of-band
Throws:
java.lang.Exception - if some error occurs

testSMimeAuthEncrypted

public void testSMimeAuthEncrypted(iaik.asn1.structures.AlgorithmID contentEA,
                                   iaik.asn1.structures.AlgorithmID keyWrapAlg,
                                   int keyLength,
                                   int recipientIndex)
                            throws java.lang.Exception
Uses class SMimeAuthEncrypted to authenticated encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content.

Parameters:
contentEA - the content-authenticated encryption algorithm to be used
keyWrapAlg - the key wrap algorithm to be used for encrypting the temporary content encryption key
keyLength - the length of the content encryption key to be created and used
recipientIndex - the index into the recipientInfos field indicating for which recipient the message shall be decrypted
Throws:
java.lang.Exception - if some error occurs

testSMimeSignedAndEncrypted

public void testSMimeSignedAndEncrypted(iaik.asn1.structures.AlgorithmID contentEA,
                                        iaik.asn1.structures.AlgorithmID keyWrapAlg,
                                        int keyLength,
                                        int recipientIndex)
                                 throws java.lang.Exception
Uses class SMimeSigned and class SMimeEncrypted to sign and encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content and verify the signature.

Parameters:
contentEA - the content encryption algorithm to be used
keyWrapAlg - the key wrap algorithm to be used for encrypting the temporary content encryption key
keyLength - the length of the content encryption key to be created and used
recipientIndex - the index into the recipientInfos field indicating for which recipient the message shall be decrypted
Throws:
java.lang.Exception - if some error occurs

testSMimeSignedAndAuthEncrypted

public void testSMimeSignedAndAuthEncrypted(iaik.asn1.structures.AlgorithmID contentEA,
                                            iaik.asn1.structures.AlgorithmID keyWrapAlg,
                                            int keyLength,
                                            int recipientIndex)
                                     throws java.lang.Exception
Uses class SMimeSigned and class SMimeAuthEncrypted to sign and authenticated encrypt some data, encode it, and finally parses the encoding to decrypt and recover the original content and verify the signature.

Parameters:
contentEA - the content-authenticated encryption algorithm to be used
keyWrapAlg - the key wrap algorithm to be used for encrypting the temporary content encryption key
keyLength - the length of the content encryption key to be created and used
recipientIndex - the index into the recipientInfos field indicating for which recipient the message shall be decrypted
Throws:
java.lang.Exception - if some error occurs

start

public void start()
Starts the demo.


main

public static void main(java.lang.String[] argv)
                 throws java.io.IOException
The main method. Reads the certificates and the private key and then starts the demos.

Throws:
java.io.IOException

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

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