org.bouncycastle.mail.smime

Class SMIMEEnvelopedGenerator

public class SMIMEEnvelopedGenerator extends SMIMEGenerator

General class for generating a pkcs7-mime message. A simple example of usage.
      SMIMEEnvelopedGenerator  fact = new SMIMEEnvelopedGenerator();

      fact.addKeyTransRecipient(cert);

      MimeBodyPart           smime = fact.generate(content, algorithm, "BC");
 
Note: Most clients expect the MimeBodyPart to be in a MimeMultipart when it's sent.
Field Summary
static StringAES128_CBC
static StringAES128_WRAP
static StringAES192_CBC
static StringAES256_CBC
static StringAES256_WRAP
static StringCAMELLIA128_CBC
static StringCAMELLIA128_WRAP
static StringCAMELLIA192_CBC
static StringCAMELLIA192_WRAP
static StringCAMELLIA256_CBC
static StringCAMELLIA256_WRAP
static StringCAST5_CBC
static StringDES_EDE3_CBC
static StringDES_EDE3_WRAP
static StringECDH_SHA1KDF
static StringIDEA_CBC
static StringRC2_CBC
static StringSEED_CBC
static StringSEED_WRAP
Constructor Summary
SMIMEEnvelopedGenerator()
base constructor
Method Summary
voidaddKeyAgreementRecipient(String agreementAlgorithm, PrivateKey senderPrivateKey, PublicKey senderPublicKey, X509Certificate recipientCert, String cekWrapAlgorithm, String provider)
Add a key agreement based recipient.
voidaddKeyTransRecipient(X509Certificate cert)
add a recipient.
voidaddKeyTransRecipient(PublicKey key, byte[] subKeyId)
add a recipient - note: this will only work on V3 and later clients.
voidaddKEKRecipient(SecretKey key, byte[] keyIdentifier)
add a KEK recipient.
MimeBodyPartgenerate(MimeBodyPart content, String encryptionOID, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider.
MimeBodyPartgenerate(MimeMessage message, String encryptionOID, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message
MimeBodyPartgenerate(MimeBodyPart content, String encryptionOID, int keySize, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider.
MimeBodyPartgenerate(MimeMessage message, String encryptionOID, int keySize, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message.
voidsetBerEncodeRecipients(boolean berEncodeRecipientSet)
Use a BER Set to store the recipient information

Field Detail

AES128_CBC

public static final String AES128_CBC

AES128_WRAP

public static final String AES128_WRAP

AES192_CBC

public static final String AES192_CBC

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 Detail

SMIMEEnvelopedGenerator

public SMIMEEnvelopedGenerator()
base constructor

Method Detail

addKeyAgreementRecipient

public void addKeyAgreementRecipient(String agreementAlgorithm, PrivateKey senderPrivateKey, PublicKey senderPublicKey, X509Certificate recipientCert, String cekWrapAlgorithm, String provider)
Add a key agreement based recipient.

Parameters: 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(X509Certificate cert)
add a recipient.

addKeyTransRecipient

public void addKeyTransRecipient(PublicKey key, byte[] subKeyId)
add a recipient - note: this will only work on V3 and later clients.

Parameters: key the recipient's public key subKeyId the subject key id for the recipient's public key

addKEKRecipient

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

generate

public MimeBodyPart generate(MimeBodyPart content, String encryptionOID, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider.

generate

public MimeBodyPart generate(MimeMessage message, String encryptionOID, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message

generate

public MimeBodyPart generate(MimeBodyPart content, String encryptionOID, int keySize, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider. The size of the encryption key is determined by keysize.

generate

public MimeBodyPart generate(MimeMessage message, String encryptionOID, int keySize, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message. The size of the encryption key used to protect the message is determined by keysize.

setBerEncodeRecipients

public void setBerEncodeRecipients(boolean berEncodeRecipientSet)
Use a BER Set to store the recipient information