IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.cms.envelopedData
Class PasswordRecipientInfoDemo

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

public class PasswordRecipientInfoDemo
extends java.lang.Object

This class shows the usage of the CMS RecipientInfo type PasswordRecipientInfo as specified by RFC 5652.


Constructor Summary
PasswordRecipientInfoDemo()
          Default constructor.
 
Method Summary
 byte[] createEnvelopedData(byte[] message, char[] password, iaik.asn1.structures.AlgorithmID keyDerivationAlg, java.security.spec.AlgorithmParameterSpec keyDerivatoinParamSpec, iaik.asn1.structures.AlgorithmID keyEncrAlg, java.security.AlgorithmParameters keyEncrParams)
          Creates a CMS EnvelopedData with a PasswordRecipientInfo and wraps it into a ContentInfo.
 byte[] createEnvelopedDataStream(byte[] message, char[] password, iaik.asn1.structures.AlgorithmID keyDerivationAlg, java.security.spec.AlgorithmParameterSpec keyDerivatoinParamSpec, iaik.asn1.structures.AlgorithmID keyEncrAlg, java.security.AlgorithmParameters keyEncrParams)
          Creates a CMS EnvelopedData with a PasswordRecipientInfo and wraps it into a ContentInfo (stream implementation).
 byte[] getEnvelopedData(byte[] encoding, char[] password, java.lang.String cekAlgName)
          PBE based decrypts the encrypted content of the given EnvelopedData object and returns the decrypted (= original) message.
 byte[] getEnvelopedDataStream(byte[] encoding, char[] password, java.lang.String cekAlgName)
          PBE based decrypts the encrypted content of the given EnvelopedData object and returns the decrypted (= original) message (stream implementation).
static void main(java.lang.String[] argv)
          Main method.
 void start()
          Starts the demo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordRecipientInfoDemo

public PasswordRecipientInfoDemo()
Default constructor.

Method Detail

createEnvelopedDataStream

public byte[] createEnvelopedDataStream(byte[] message,
                                        char[] password,
                                        iaik.asn1.structures.AlgorithmID keyDerivationAlg,
                                        java.security.spec.AlgorithmParameterSpec keyDerivatoinParamSpec,
                                        iaik.asn1.structures.AlgorithmID keyEncrAlg,
                                        java.security.AlgorithmParameters keyEncrParams)
                                 throws iaik.cms.CMSException,
                                        java.io.IOException
Creates a CMS EnvelopedData with a PasswordRecipientInfo and wraps it into a ContentInfo (stream implementation).

Parameters:
message - the message to be enveloped, as byte representation
password - the password from which to derive the key encryption key (kek)
keyDerivationAlg - the key derivation function to be used for deriving the kek
keyDerivatoinParamSpec - any parameters required by the key derivation function
keyEncrAlg - the ID of the key-encryption (key-wrap) algorithm to be used for encrypting the content-encryption key
keyEncrParams - any algorithm parameters to be used for intializing the key wrap cipher
Returns:
the 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,
                                     char[] password,
                                     java.lang.String cekAlgName)
                              throws iaik.cms.CMSException,
                                     java.io.IOException
PBE based decrypts the encrypted content of the given EnvelopedData object and returns the decrypted (= original) message (stream implementation).

Parameters:
encoding - the encoded ContentInfo containing an EnvelopedData object
password - the password from which to derive the key-encryption key (kek) to be used for decrypting the content-encryption key (cek)
cekAlgName - the name of the cek (content encryption key) algorithm
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,
                                  char[] password,
                                  iaik.asn1.structures.AlgorithmID keyDerivationAlg,
                                  java.security.spec.AlgorithmParameterSpec keyDerivatoinParamSpec,
                                  iaik.asn1.structures.AlgorithmID keyEncrAlg,
                                  java.security.AlgorithmParameters keyEncrParams)
                           throws iaik.cms.CMSException
Creates a CMS EnvelopedData with a PasswordRecipientInfo and wraps it into a ContentInfo.

Parameters:
message - the message to be enveloped, as byte representation
password - the password from which to derive the key encryption key (kek)
keyDerivationAlg - the key derivation function to be used for deriving the kek
keyDerivatoinParamSpec - any parameters required by the key derivation function
keyEncrAlg - the ID of the key-encryption (key-wrap) algorithm to be used for encrypting the content-encryption key
keyEncrParams - any algorithm parameters to be used for intializing the key wrap cipher
Returns:
the encoded ContentInfo containing the EnvelopedData object just created
Throws:
iaik.cms.CMSException - if the EnvelopedData object cannot be created

getEnvelopedData

public byte[] getEnvelopedData(byte[] encoding,
                               char[] password,
                               java.lang.String cekAlgName)
                        throws iaik.cms.CMSException,
                               java.io.IOException
PBE based decrypts the encrypted content of the given EnvelopedData object and returns the decrypted (= original) message.

Parameters:
encoding - the encoded ContentInfo containing an EnvelopedData object
password - the password from which to derive the key-encryption key (kek) to be used for decrypting the content-encryption key (cek)
cekAlgName - the name of the cek (content encryption key) algorithm
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()
Starts the demo.


main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
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