org.bouncycastle.cms

Class CMSEnvelopedGenerator

Known Direct Subclasses:
CMSEnvelopedDataGenerator, CMSEnvelopedDataStreamGenerator

public class CMSEnvelopedGenerator
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");
 

Nested Class Summary

protected class
CMSEnvelopedGenerator.RecipientInf

Field Summary

static String
AES128_CBC
static String
AES128_WRAP
static String
AES192_CBC
static String
AES192_WRAP
static String
AES256_CBC
static String
AES256_WRAP
static String
CAMELLIA128_CBC
static String
CAMELLIA128_WRAP
static String
CAMELLIA192_CBC
static String
CAMELLIA192_WRAP
static String
CAMELLIA256_CBC
static String
CAMELLIA256_WRAP
static String
CAST5_CBC
static String
DES_EDE3_CBC
static String
DES_EDE3_WRAP
static String
ECDH_SHA1KDF
static String
IDEA_CBC
static String
RC2_CBC
static String
SEED_CBC
static String
SEED_WRAP

Constructor Summary

CMSEnvelopedGenerator()
base constructor

Method Summary

void
addKEKRecipient(SecretKey key, byte[] keyIdentifier)
add a KEK recipient.
void
addKeyAgreementRecipient(String agreementAlgorithm, PrivateKey senderPrivateKey, PublicKey senderPublicKey, X509Certificate recipientCert, String cekWrapAlgorithm, String provider)
Add a key agreement based recipient.
void
addKeyTransRecipient(PublicKey key, byte[] subKeyId)
add a recipient
void
addKeyTransRecipient(X509Certificate cert)
add a recipient.
void
addPasswordRecipient(CMSPBEKey pbeKey, String kekAlgorithmOid)
protected AlgorithmParameters
generateParameters(String encryptionOID, SecretKey encKey, String encProvider)
protected AlgorithmIdentifier
getAlgorithmIdentifier(String encryptionOID, AlgorithmParameters params)

Field Details

AES128_CBC

public static final String AES128_CBC

AES128_WRAP

public static final String AES128_WRAP

AES192_CBC

public static final String AES192_CBC

AES192_WRAP

public static final String AES192_WRAP

AES256_CBC

public static final String AES256_CBC

AES256_WRAP

public static final String AES256_WRAP

CAMELLIA128_CBC

public static final String CAMELLIA128_CBC

CAMELLIA128_WRAP

public static final String CAMELLIA128_WRAP

CAMELLIA192_CBC

public static final String CAMELLIA192_CBC

CAMELLIA192_WRAP

public static final String CAMELLIA192_WRAP

CAMELLIA256_CBC

public static final String CAMELLIA256_CBC

CAMELLIA256_WRAP

public static final String CAMELLIA256_WRAP

CAST5_CBC

public static final String CAST5_CBC

DES_EDE3_CBC

public static final String DES_EDE3_CBC

DES_EDE3_WRAP

public static final String DES_EDE3_WRAP

ECDH_SHA1KDF

public static final String ECDH_SHA1KDF

IDEA_CBC

public static final String IDEA_CBC

RC2_CBC

public static final String RC2_CBC

SEED_CBC

public static final String SEED_CBC

SEED_WRAP

public static final String SEED_WRAP

Constructor Details

CMSEnvelopedGenerator

public CMSEnvelopedGenerator()
base constructor

Method Details

addKEKRecipient

public void addKEKRecipient(SecretKey key,
                            byte[] keyIdentifier)
add a KEK recipient.
Parameters:
key - the secret key to use for wrapping
keyIdentifier - the byte string that identifies the key

addKeyAgreementRecipient

public void addKeyAgreementRecipient(String agreementAlgorithm,
                                     PrivateKey senderPrivateKey,
                                     PublicKey senderPublicKey,
                                     X509Certificate recipientCert,
                                     String cekWrapAlgorithm,
                                     String provider)
            throws NoSuchProviderException,
                   NoSuchAlgorithmException,
                   InvalidKeyException
Add a key agreement based recipient.
Parameters:
agreementAlgorithm - key agreement algorithm to use.
senderPrivateKey - private key to initialise sender side of agreement with.
senderPublicKey - sender public key to include with message.
recipientCert - recipient's public key certificate.
cekWrapAlgorithm - OID for key wrapping algorithm to use.
provider - provider to use for the agreement calculation.

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.
Parameters:
cert - recipient's public key certificate

addPasswordRecipient

public void addPasswordRecipient(CMSPBEKey pbeKey,
                                 String kekAlgorithmOid)

generateParameters

protected AlgorithmParameters generateParameters(String encryptionOID,
                                                 SecretKey encKey,
                                                 String encProvider)
            throws NoSuchProviderException,
                   CMSException

getAlgorithmIdentifier

protected AlgorithmIdentifier getAlgorithmIdentifier(String encryptionOID,
                                                     AlgorithmParameters params)
            throws IOException