Bouncy Castle Cryptography 1.46

org.bouncycastle.cms
Class CMSEnvelopedGenerator

java.lang.Object
  extended by org.bouncycastle.cms.CMSEnvelopedGenerator
Direct Known Subclasses:
CMSAuthenticatedGenerator, CMSEnvelopedDataGenerator, CMSEnvelopedDataStreamGenerator

public class CMSEnvelopedGenerator
extends java.lang.Object

General class for generating a CMS enveloped-data message.


Field Summary
static java.lang.String AES128_CBC
           
static java.lang.String AES128_WRAP
           
static java.lang.String AES192_CBC
           
static java.lang.String AES192_WRAP
           
static java.lang.String AES256_CBC
           
static java.lang.String AES256_WRAP
           
static java.lang.String CAMELLIA128_CBC
           
static java.lang.String CAMELLIA128_WRAP
           
static java.lang.String CAMELLIA192_CBC
           
static java.lang.String CAMELLIA192_WRAP
           
static java.lang.String CAMELLIA256_CBC
           
static java.lang.String CAMELLIA256_WRAP
           
static java.lang.String CAST5_CBC
           
static java.lang.String DES_EDE3_CBC
           
static java.lang.String DES_EDE3_WRAP
           
static java.lang.String ECDH_SHA1KDF
           
static java.lang.String ECMQV_SHA1KDF
           
static java.lang.String IDEA_CBC
           
static java.lang.String RC2_CBC
           
static java.lang.String SEED_CBC
           
static java.lang.String SEED_WRAP
           
protected  CMSAttributeTableGenerator unprotectedAttributeGenerator
           
 
Constructor Summary
CMSEnvelopedGenerator()
          base constructor
CMSEnvelopedGenerator(java.security.SecureRandom rand)
          constructor allowing specific source of randomness
 
Method Summary
 void addKEKRecipient(javax.crypto.SecretKey key, byte[] keyIdentifier)
          Deprecated. use the addRecipientGenerator and JceKEKRecipientInfoGenerator
 void addKEKRecipient(javax.crypto.SecretKey key, KEKIdentifier kekIdentifier)
          Deprecated. use the addRecipientGenerator and JceKEKRecipientInfoGenerator
 void addKeyAgreementRecipient(java.lang.String agreementAlgorithm, java.security.PrivateKey senderPrivateKey, java.security.PublicKey senderPublicKey, java.security.cert.X509Certificate recipientCert, java.lang.String cekWrapAlgorithm, java.security.Provider provider)
          Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator
 void addKeyAgreementRecipient(java.lang.String agreementAlgorithm, java.security.PrivateKey senderPrivateKey, java.security.PublicKey senderPublicKey, java.security.cert.X509Certificate recipientCert, java.lang.String cekWrapAlgorithm, java.lang.String provider)
          Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator
 void addKeyAgreementRecipients(java.lang.String agreementAlgorithm, java.security.PrivateKey senderPrivateKey, java.security.PublicKey senderPublicKey, java.util.Collection recipientCerts, java.lang.String cekWrapAlgorithm, java.security.Provider provider)
          Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator
 void addKeyAgreementRecipients(java.lang.String agreementAlgorithm, java.security.PrivateKey senderPrivateKey, java.security.PublicKey senderPublicKey, java.util.Collection recipientCerts, java.lang.String cekWrapAlgorithm, java.lang.String provider)
          Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator
 void addKeyTransRecipient(java.security.PublicKey key, byte[] subKeyId)
          Deprecated. use the addRecipientGenerator and JceKeyTransRecipientInfoGenerator
 void addKeyTransRecipient(java.security.cert.X509Certificate cert)
          Deprecated. use the addRecipientGenerator and JceKeyTransRecipientInfoGenerator
 void addPasswordRecipient(CMSPBEKey pbeKey, java.lang.String kekAlgorithmOid)
          Deprecated. use addRecipientGenerator and JcePasswordRecipientInfoGenerator
 void addRecipientInfoGenerator(RecipientInfoGenerator recipientGenerator)
          Add a generator to produce the recipient info required.
protected  java.security.AlgorithmParameters generateParameters(java.lang.String encryptionOID, javax.crypto.SecretKey encKey, java.security.Provider encProvider)
           
protected  AlgorithmIdentifier getAlgorithmIdentifier(java.lang.String encryptionOID, java.security.AlgorithmParameters params)
           
 void setUnprotectedAttributeGenerator(CMSAttributeTableGenerator unprotectedAttributeGenerator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DES_EDE3_CBC

public static final java.lang.String DES_EDE3_CBC

RC2_CBC

public static final java.lang.String RC2_CBC

IDEA_CBC

public static final java.lang.String IDEA_CBC
See Also:
Constant Field Values

CAST5_CBC

public static final java.lang.String CAST5_CBC
See Also:
Constant Field Values

AES128_CBC

public static final java.lang.String AES128_CBC

AES192_CBC

public static final java.lang.String AES192_CBC

AES256_CBC

public static final java.lang.String AES256_CBC

CAMELLIA128_CBC

public static final java.lang.String CAMELLIA128_CBC

CAMELLIA192_CBC

public static final java.lang.String CAMELLIA192_CBC

CAMELLIA256_CBC

public static final java.lang.String CAMELLIA256_CBC

SEED_CBC

public static final java.lang.String SEED_CBC

DES_EDE3_WRAP

public static final java.lang.String DES_EDE3_WRAP

AES128_WRAP

public static final java.lang.String AES128_WRAP

AES192_WRAP

public static final java.lang.String AES192_WRAP

AES256_WRAP

public static final java.lang.String AES256_WRAP

CAMELLIA128_WRAP

public static final java.lang.String CAMELLIA128_WRAP

CAMELLIA192_WRAP

public static final java.lang.String CAMELLIA192_WRAP

CAMELLIA256_WRAP

public static final java.lang.String CAMELLIA256_WRAP

SEED_WRAP

public static final java.lang.String SEED_WRAP

ECDH_SHA1KDF

public static final java.lang.String ECDH_SHA1KDF

ECMQV_SHA1KDF

public static final java.lang.String ECMQV_SHA1KDF

unprotectedAttributeGenerator

protected CMSAttributeTableGenerator unprotectedAttributeGenerator
Constructor Detail

CMSEnvelopedGenerator

public CMSEnvelopedGenerator()
base constructor


CMSEnvelopedGenerator

public CMSEnvelopedGenerator(java.security.SecureRandom rand)
constructor allowing specific source of randomness

Parameters:
rand - instance of SecureRandom to use
Method Detail

setUnprotectedAttributeGenerator

public void setUnprotectedAttributeGenerator(CMSAttributeTableGenerator unprotectedAttributeGenerator)

addKeyTransRecipient

public void addKeyTransRecipient(java.security.cert.X509Certificate cert)
                          throws java.lang.IllegalArgumentException
Deprecated. use the addRecipientGenerator and JceKeyTransRecipientInfoGenerator

add a recipient.

Parameters:
cert - recipient's public key certificate
Throws:
java.lang.IllegalArgumentException - if there is a problem with the certificate

addKeyTransRecipient

public void addKeyTransRecipient(java.security.PublicKey key,
                                 byte[] subKeyId)
                          throws java.lang.IllegalArgumentException
Deprecated. use the addRecipientGenerator and JceKeyTransRecipientInfoGenerator

add a recipient

Parameters:
key - the public key used by the recipient
subKeyId - the identifier for the recipient's public key
Throws:
java.lang.IllegalArgumentException - if there is a problem with the key

addKEKRecipient

public void addKEKRecipient(javax.crypto.SecretKey key,
                            byte[] keyIdentifier)
Deprecated. use the addRecipientGenerator and JceKEKRecipientInfoGenerator

add a KEK recipient.

Parameters:
key - the secret key to use for wrapping
keyIdentifier - the byte string that identifies the key

addKEKRecipient

public void addKEKRecipient(javax.crypto.SecretKey key,
                            KEKIdentifier kekIdentifier)
Deprecated. use the addRecipientGenerator and JceKEKRecipientInfoGenerator

add a KEK recipient.

Parameters:
key - the secret key to use for wrapping
kekIdentifier - a KEKIdentifier structure (identifies the key)

addPasswordRecipient

public void addPasswordRecipient(CMSPBEKey pbeKey,
                                 java.lang.String kekAlgorithmOid)
Deprecated. use addRecipientGenerator and JcePasswordRecipientInfoGenerator

Parameters:
pbeKey - PBE key
kekAlgorithmOid - key encryption algorithm to use.

addKeyAgreementRecipient

public void addKeyAgreementRecipient(java.lang.String agreementAlgorithm,
                                     java.security.PrivateKey senderPrivateKey,
                                     java.security.PublicKey senderPublicKey,
                                     java.security.cert.X509Certificate recipientCert,
                                     java.lang.String cekWrapAlgorithm,
                                     java.lang.String provider)
                              throws java.security.NoSuchProviderException,
                                     java.security.NoSuchAlgorithmException,
                                     java.security.InvalidKeyException
Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator

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.
Throws:
java.security.NoSuchProviderException - if the specified provider cannot be found
java.security.NoSuchAlgorithmException - if the algorithm requested cannot be found
java.security.InvalidKeyException - if the keys are inappropriate for the algorithm specified

addKeyAgreementRecipient

public void addKeyAgreementRecipient(java.lang.String agreementAlgorithm,
                                     java.security.PrivateKey senderPrivateKey,
                                     java.security.PublicKey senderPublicKey,
                                     java.security.cert.X509Certificate recipientCert,
                                     java.lang.String cekWrapAlgorithm,
                                     java.security.Provider provider)
                              throws java.security.NoSuchAlgorithmException,
                                     java.security.InvalidKeyException
Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator

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.
Throws:
java.security.NoSuchAlgorithmException - if the algorithm requested cannot be found
java.security.InvalidKeyException - if the keys are inappropriate for the algorithm specified

addKeyAgreementRecipients

public void addKeyAgreementRecipients(java.lang.String agreementAlgorithm,
                                      java.security.PrivateKey senderPrivateKey,
                                      java.security.PublicKey senderPublicKey,
                                      java.util.Collection recipientCerts,
                                      java.lang.String cekWrapAlgorithm,
                                      java.lang.String provider)
                               throws java.security.NoSuchProviderException,
                                      java.security.NoSuchAlgorithmException,
                                      java.security.InvalidKeyException
Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator

Add multiple key agreement based recipients (sharing a single KeyAgreeRecipientInfo structure).

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.
recipientCerts - recipients' public key certificates.
cekWrapAlgorithm - OID for key wrapping algorithm to use.
provider - provider to use for the agreement calculation.
Throws:
java.security.NoSuchAlgorithmException - if the algorithm requested cannot be found
java.security.InvalidKeyException - if the keys are inappropriate for the algorithm specified
java.security.NoSuchProviderException

addKeyAgreementRecipients

public void addKeyAgreementRecipients(java.lang.String agreementAlgorithm,
                                      java.security.PrivateKey senderPrivateKey,
                                      java.security.PublicKey senderPublicKey,
                                      java.util.Collection recipientCerts,
                                      java.lang.String cekWrapAlgorithm,
                                      java.security.Provider provider)
                               throws java.security.NoSuchAlgorithmException,
                                      java.security.InvalidKeyException
Deprecated. use the addRecipientGenerator and JceKeyAgreeRecipientInfoGenerator

Add multiple key agreement based recipients (sharing a single KeyAgreeRecipientInfo structure).

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.
recipientCerts - recipients' public key certificates.
cekWrapAlgorithm - OID for key wrapping algorithm to use.
provider - provider to use for the agreement calculation.
Throws:
java.security.NoSuchAlgorithmException - if the algorithm requested cannot be found
java.security.InvalidKeyException - if the keys are inappropriate for the algorithm specified

addRecipientInfoGenerator

public void addRecipientInfoGenerator(RecipientInfoGenerator recipientGenerator)
Add a generator to produce the recipient info required.

Parameters:
recipientGenerator - a generator of a recipient info object.

getAlgorithmIdentifier

protected AlgorithmIdentifier getAlgorithmIdentifier(java.lang.String encryptionOID,
                                                     java.security.AlgorithmParameters params)
                                              throws java.io.IOException
Throws:
java.io.IOException

generateParameters

protected java.security.AlgorithmParameters generateParameters(java.lang.String encryptionOID,
                                                               javax.crypto.SecretKey encKey,
                                                               java.security.Provider encProvider)
                                                        throws CMSException
Throws:
CMSException

Bouncy Castle Cryptography 1.46