IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.cms.envelopedData
Class ArcFourEnvelopedDataDemo

java.lang.Object
  extended by demo.cms.envelopedData.ArcFourEnvelopedDataDemo

public class ArcFourEnvelopedDataDemo
extends java.lang.Object

This class demonstrates the EnvelopedDataStream/EncryptedContentInfoStream usages for the ARCFOUR algorithm. The ARCFOUR stream cipher is believed to be compatible with RC4[TM], a proprietary cipher of RSA Security Inc..

This demo compares the usage of class EnvelopedDataStream for encrypting the content using ARCFOUR with automatical (transparent) key/parameter handling against explicit key/parameter/EncrypedContentInfoStream handling.

All keys and certificates are read from a keystore created by the SetupCMSKeyStore program.

ARCFOUR requires no parameters.


Constructor Summary
ArcFourEnvelopedDataDemo()
          Setup the demo certificate chains.
 
Method Summary
 byte[] createEncryptedContentInfoStream(byte[] message, iaik.asn1.structures.AlgorithmID cea, int keyLength)
          Creates a CMS EnvelopedDataStream message.
 byte[] createEnvelopedDataStream(byte[] message, iaik.asn1.structures.AlgorithmID contentEA, int keyLength)
          Creates a CMS EnvelopedDataStream message.
 byte[] getEncryptedContentInfoStream(byte[] encoding, java.security.PrivateKey privateKey, int recipientInfoIndex)
          Decrypts the encrypted content of the given EnvelopedData object for the specified recipient and returns the decrypted (= original) message.
 byte[] getEnvelopedDataStream(byte[] encoding, java.security.PrivateKey privateKey, int recipientInfoIndex)
          Decrypts the encrypted content of the given EnvelopedData object for the specified recipient and returns the decrypted (= original) message.
static void main(java.lang.String[] argv)
          The main method.
 void start()
          Starts the test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArcFourEnvelopedDataDemo

public ArcFourEnvelopedDataDemo()
                         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

createEnvelopedDataStream

public byte[] createEnvelopedDataStream(byte[] message,
                                        iaik.asn1.structures.AlgorithmID contentEA,
                                        int keyLength)
                                 throws java.lang.Exception
Creates a CMS EnvelopedDataStream message.

Parameters:
message - the message to be enveloped, as byte representation
contentEA - the content encryption algorithm
keyLength - the key length for the symmetric key
Returns:
the DER encoding of the EnvelopedData object just created
Throws:
iaik.cms.CMSException - if the EnvelopedData object cannot be created
java.lang.Exception

createEncryptedContentInfoStream

public byte[] createEncryptedContentInfoStream(byte[] message,
                                               iaik.asn1.structures.AlgorithmID cea,
                                               int keyLength)
                                        throws java.lang.Exception
Creates a CMS EnvelopedDataStream message.

Keys and parameters, and EncryptedContentInfoStream are created outside the EnvelopedDataStream class.

Parameters:
message - the message to be enveloped, as byte representation
cea - the content encryption algorithm
keyLength - the key length for the symmetric key
Returns:
the DER encoding of the EnvelopedData object just created
Throws:
java.lang.Exception - if the EnvelopedData object cannot be created

getEncryptedContentInfoStream

public byte[] getEncryptedContentInfoStream(byte[] encoding,
                                            java.security.PrivateKey privateKey,
                                            int recipientInfoIndex)
                                     throws java.lang.Exception
Decrypts the encrypted content of the given EnvelopedData object for the specified recipient and returns the decrypted (= original) message.

Decryption and cipher setup and EncryptedContentInfoStrean processing is performed outside class EnvelopedDataStream.

Parameters:
encoding - the EnvelopedData object as DER encoded byte array
privateKey - the private key to decrypt the message
recipientInfoIndex - the index into the RecipientInfo array to which the specified private key belongs
Returns:
the recovered message, as byte array
Throws:
java.lang.Exception - if the message cannot be recovered

getEnvelopedDataStream

public byte[] getEnvelopedDataStream(byte[] encoding,
                                     java.security.PrivateKey privateKey,
                                     int recipientInfoIndex)
                              throws java.lang.Exception
Decrypts the encrypted content of the given EnvelopedData object for the specified recipient and returns the decrypted (= original) message.

Parameters:
encoding - the EnvelopedData object as DER encoded byte array
privateKey - the private key to decrypt the message
recipientInfoIndex - the index into the RecipientInfo array to which the specified private key belongs
Returns:
the recovered message, as byte array
Throws:
java.lang.Exception - if the message cannot be recovered

start

public void start()
Starts the test.


main

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

Throws:
java.lang.Exception - if some error occurs

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

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