IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.cms.envelopedData
Class OaepEnvelopedDataDemo

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

public class OaepEnvelopedDataDemo
extends java.lang.Object

This class demonstrates the CMS EnvelopedData implementation for the RSA-OAEP (PKCS#1v2.1) algorithm.

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

Version:
File Revision 21

Constructor Summary
OaepEnvelopedDataDemo()
          Setup the demo certificate chains.
 
Method Summary
 byte[] createEnvelopedData(byte[] message)
          Creates a CMS EnvelopedData message.
 byte[] createEnvelopedDataStream(byte[] message)
          Creates a CMS EnvelopedDataStream message.
 byte[] getEnvelopedData(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)
          Main method.
 void start()
          Shows thw CMS EnvelopedData implementation for the RSA-OAEP (PKCS#1v2.1) algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OaepEnvelopedDataDemo

public OaepEnvelopedDataDemo()
                      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)
                                 throws iaik.cms.CMSException,
                                        java.io.IOException
Creates a CMS EnvelopedDataStream message.

Parameters:
message - the message to be enveloped, as byte representation
Returns:
the BER encoded ContentInfo containing the EnvelopedData object just created
Throws:
iaik.cms.CMSException - if the EnvelopedData object cannot be created
java.io.IOException - if an I/O error occurs

getEnvelopedDataStream

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

Parameters:
encoding - the BER encoded ContentInfo containing an EnvelopedData object
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:
iaik.cms.CMSException - if the message cannot be recovered
java.io.IOException - if an I/O error occurs

createEnvelopedData

public byte[] createEnvelopedData(byte[] message)
                           throws iaik.cms.CMSException,
                                  java.io.IOException
Creates a CMS EnvelopedData message.

Parameters:
message - the message to be enveloped, as byte representation
Returns:
a BER encoded ContentInfo holding the EnvelopedData object just created
Throws:
iaik.cms.CMSException - if the EnvelopedData object cannot be created
java.io.IOException - if an I/O error occurs

getEnvelopedData

public byte[] getEnvelopedData(byte[] encoding,
                               java.security.PrivateKey privateKey,
                               int recipientInfoIndex)
                        throws iaik.cms.CMSException,
                               java.io.IOException
Decrypts the encrypted content of the given EnvelopedData object for the specified recipient and returns the decrypted (= original) message.

Parameters:
encoding - the ContentInfo encoding holding an EnvelopedData
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:
iaik.cms.CMSException - if the message cannot be recovered
java.io.IOException - if an I/O error occurs

start

public void start()
Shows thw CMS EnvelopedData implementation for the RSA-OAEP (PKCS#1v2.1) algorithm.


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 the keystore file
java.lang.Exception

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

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