IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.cms.pkcs7cms
Class PKCS7CMSEncryptedDataDemo

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

public class PKCS7CMSEncryptedDataDemo
extends java.lang.Object

Compares the usage of IAIK CMS with the IAIK PKCS#7 EncryptedData(Stream) implementation.


Constructor Summary
PKCS7CMSEncryptedDataDemo()
          Default constructor.
 
Method Summary
 iaik.asn1.ASN1Object createEncryptedData(byte[] message, iaik.asn1.structures.AlgorithmID pbeAlgorithm, char[] password)
          Creates a CMS EncryptedData message.
 byte[] createEncryptedDataStream(byte[] message, iaik.asn1.structures.AlgorithmID pbeAlgorithm, char[] password)
          Creates a CMS EncryptedDataStream message.
 iaik.asn1.ASN1Object createPKCS7EncryptedData(byte[] message, iaik.asn1.structures.AlgorithmID pbeAlgorithm, char[] password)
          Creates a PKCS#7 EncryptedData message.
 byte[] createPKCS7EncryptedDataStream(byte[] message, iaik.asn1.structures.AlgorithmID pbeAlgorithm, char[] password)
          Creates a PKCS#7 EncryptedDataStream message.
 byte[] getEncryptedData(iaik.asn1.ASN1Object asn1Object, char[] password)
          Decrypts the PBE-encrypted content of the given CMS EncryptedData object using the specified password and returns the decrypted (= original) message.
 byte[] getEncryptedDataStream(byte[] encoding, char[] password)
          Decrypts the PBE-encrypted content of the given CMS EncryptedData object using the specified password and returns the decrypted (= original) message.
 byte[] getPKCS7EncryptedData(iaik.asn1.ASN1Object asn1Object, char[] password)
          Decrypts the PBE-encrypted content of the given PKCS#7 EncryptedData object using the specified password and returns the decrypted (= original) message.
 byte[] getPKCS7EncryptedDataStream(byte[] encoding, char[] password)
          Decrypts the PBE-encrypted content of the given PKCS#7 EncryptedData object using the specified password and returns the decrypted (= original) message.
static void main(java.lang.String[] argv)
          Tests the IAIK CMS against the IAIK PKCS#7 EncryptedData(Stream) implementation.
 void start()
          Starts the tests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PKCS7CMSEncryptedDataDemo

public PKCS7CMSEncryptedDataDemo()
Default constructor.

Method Detail

createEncryptedDataStream

public byte[] createEncryptedDataStream(byte[] message,
                                        iaik.asn1.structures.AlgorithmID pbeAlgorithm,
                                        char[] password)
                                 throws iaik.cms.CMSException,
                                        java.io.IOException
Creates a CMS EncryptedDataStream message.

The supplied content is PBE-encrypted using the specified password.

Parameters:
message - the message to be encrypted, as byte representation
pbeAlgorithm - the PBE algorithm to be used
password - the password
Returns:
the DER encoding of the EncryptedData object just created
Throws:
iaik.cms.CMSException - if the EncryptedData object cannot be created
java.io.IOException - if an I/O error occurs

getEncryptedDataStream

public byte[] getEncryptedDataStream(byte[] encoding,
                                     char[] password)
                              throws iaik.cms.CMSException,
                                     java.io.IOException
Decrypts the PBE-encrypted content of the given CMS EncryptedData object using the specified password and returns the decrypted (= original) message.

Parameters:
encoding - the EncryptedData object as DER encoded byte array
password - the password to decrypt the message
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

createEncryptedData

public iaik.asn1.ASN1Object createEncryptedData(byte[] message,
                                                iaik.asn1.structures.AlgorithmID pbeAlgorithm,
                                                char[] password)
                                         throws iaik.cms.CMSException,
                                                java.io.IOException
Creates a CMS EncryptedData message.

The supplied content is PBE-encrypted using the specified password.

Parameters:
message - the message to be encrypted, as byte representation
pbeAlgorithm - the PBE algorithm to be used
password - the password
Returns:
the DER encoding of the EncryptedData object just created
Throws:
iaik.cms.CMSException - if the EncryptedData object cannot be created
java.io.IOException - if an I/O error occurs

getEncryptedData

public byte[] getEncryptedData(iaik.asn1.ASN1Object asn1Object,
                               char[] password)
                        throws iaik.cms.CMSException,
                               java.io.IOException
Decrypts the PBE-encrypted content of the given CMS EncryptedData object using the specified password and returns the decrypted (= original) message.

Parameters:
asn1Object - the EncryptedData object as ASN1Object
password - the password to decrypt the message
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

createPKCS7EncryptedDataStream

public byte[] createPKCS7EncryptedDataStream(byte[] message,
                                             iaik.asn1.structures.AlgorithmID pbeAlgorithm,
                                             char[] password)
                                      throws iaik.pkcs.PKCSException,
                                             java.io.IOException
Creates a PKCS#7 EncryptedDataStream message.

The supplied content is PBE-encrypted using the specified password.

Parameters:
message - the message to be encrypted, as byte representation
pbeAlgorithm - the PBE algorithm to be used
password - the password
Returns:
the DER encoding of the EncryptedData object just created
Throws:
iaik.pkcs.PKCSException - if the EncryptedData object cannot be created
java.io.IOException - if an I/O error occurs

getPKCS7EncryptedDataStream

public byte[] getPKCS7EncryptedDataStream(byte[] encoding,
                                          char[] password)
                                   throws iaik.pkcs.PKCSException,
                                          java.io.IOException
Decrypts the PBE-encrypted content of the given PKCS#7 EncryptedData object using the specified password and returns the decrypted (= original) message.

Parameters:
encoding - the EncryptedData object as DER encoded byte array
password - the password to decrypt the message
Returns:
the recovered message, as byte array
Throws:
iaik.pkcs.PKCSException - if the message cannot be recovered
java.io.IOException - if an I/O error occurs

createPKCS7EncryptedData

public iaik.asn1.ASN1Object createPKCS7EncryptedData(byte[] message,
                                                     iaik.asn1.structures.AlgorithmID pbeAlgorithm,
                                                     char[] password)
                                              throws iaik.pkcs.PKCSException,
                                                     java.io.IOException
Creates a PKCS#7 EncryptedData message.

The supplied content is PBE-encrypted using the specified password.

Parameters:
message - the message to be encrypted, as byte representation
pbeAlgorithm - the PBE algorithm to be used
password - the password
Returns:
the DER encoding of the EncryptedData object just created
Throws:
iaik.pkcs.PKCSException - if the EncryptedData object cannot be created
java.io.IOException - if an I/O error occurs

getPKCS7EncryptedData

public byte[] getPKCS7EncryptedData(iaik.asn1.ASN1Object asn1Object,
                                    char[] password)
                             throws iaik.pkcs.PKCSException,
                                    java.io.IOException
Decrypts the PBE-encrypted content of the given PKCS#7 EncryptedData object using the specified password and returns the decrypted (= original) message.

Parameters:
asn1Object - the EncryptedData object as ASN1Object
password - the password to decrypt the message
Returns:
the recovered message, as byte array
Throws:
iaik.pkcs.PKCSException - if the message cannot be recovered
java.io.IOException - if an I/O error occurs

start

public void start()
Starts the tests.


main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Tests the IAIK CMS against the IAIK PKCS#7 EncryptedData(Stream) implementation.

Throws:
java.lang.Exception

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

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