org.bouncycastle.cms

Class CMSEnvelopedDataGenerator


public class CMSEnvelopedDataGenerator
extends java.lang.Object

General class for generating a CMS enveloped-data message. A simple example of usage.
      CMSEnvelopedDataGenerator  fact = new CMSEnvelopedDataGenerator();

      fact.addKeyTransRecipient(cert);

      CMSEnvelopedData         data = fact.generate(content, algorithm, "BC");
 

Field Summary

static String
AES128_CBC
static String
AES192_CBC
static String
AES256_CBC
static String
CAST5_CBC
static String
DES_EDE3_CBC
static String
IDEA_CBC
static String
RC2_CBC

Constructor Summary

CMSEnvelopedDataGenerator()
base constructor

Method Summary

void
addKEKRecipient(SecretKey key, byte[] keyIdentifier)
add a KEK recipient.
void
addKeyTransRecipient(PublicKey key, byte[] subKeyId)
add a recipient
void
addKeyTransRecipient(X509Certificate cert)
add a recipient.
CMSEnvelopedData
generate(CMSProcessable content, String encryptionOID, String provider)
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.
CMSEnvelopedData
generate(CMSProcessable content, String encryptionOID, int keySize, String provider)
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.

Field Details

AES128_CBC

public static final String AES128_CBC

AES192_CBC

public static final String AES192_CBC

AES256_CBC

public static final String AES256_CBC

CAST5_CBC

public static final String CAST5_CBC

DES_EDE3_CBC

public static final String DES_EDE3_CBC

IDEA_CBC

public static final String IDEA_CBC

RC2_CBC

public static final String RC2_CBC

Constructor Details

CMSEnvelopedDataGenerator

public CMSEnvelopedDataGenerator()
base constructor

Method Details

addKEKRecipient

public void addKEKRecipient(SecretKey key,
                            byte[] keyIdentifier)
add a KEK recipient.

addKeyTransRecipient

public void addKeyTransRecipient(PublicKey key,
                                 byte[] subKeyId)
            throws IllegalArgumentException
add a recipient
Parameters:
key - the public key used by the recipient
subKeyId - the identifier for the recipient's public key

addKeyTransRecipient

public void addKeyTransRecipient(X509Certificate cert)
            throws IllegalArgumentException
add a recipient.

generate

public CMSEnvelopedData generate(CMSProcessable content,
                                 String encryptionOID,
                                 String provider)
            throws NoSuchAlgorithmException,
                   NoSuchProviderException,
                   CMSException
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.

generate

public CMSEnvelopedData generate(CMSProcessable content,
                                 String encryptionOID,
                                 int keySize,
                                 String provider)
            throws NoSuchAlgorithmException,
                   NoSuchProviderException,
                   CMSException
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.