Bouncy Castle Cryptography 1.30

org.bouncycastle.cms
Class CMSEnvelopedDataStreamGenerator

java.lang.Object
  |
  +--org.bouncycastle.cms.CMSEnvelopedDataStreamGenerator

public class CMSEnvelopedDataStreamGenerator
extends java.lang.Object

General class for generating a CMS enveloped-data message stream.

A simple example of usage.

      CMSEnvelopedDataStreamGenerator edGen = new CMSEnvelopedDataStreamGenerator();

      edGen.addKeyTransRecipient(cert);

      ByteArrayOutputStream  bOut = new ByteArrayOutputStream();
      
      OutputStream out = edGen.open(
                              bOut, CMSEnvelopedDataGenerator.AES128_CBC, "BC");*
      out.write(data);
      
      out.close();
 


Field Summary
static java.lang.String AES128_CBC
           
static java.lang.String AES192_CBC
           
static java.lang.String AES256_CBC
           
static java.lang.String CAST5_CBC
           
static java.lang.String DES_EDE3_CBC
           
static java.lang.String IDEA_CBC
           
static java.lang.String RC2_CBC
           
 
Constructor Summary
CMSEnvelopedDataStreamGenerator()
          base constructor
 
Method Summary
 void addKEKRecipient(javax.crypto.SecretKey key, byte[] keyIdentifier)
          add a KEK recipient.
 void addKeyTransRecipient(java.security.PublicKey key, byte[] subKeyId)
          add a recipient
 void addKeyTransRecipient(java.security.cert.X509Certificate cert)
          add a recipient.
 java.io.OutputStream open(java.io.OutputStream out, java.lang.String encryptionOID, int keySize, java.lang.String provider)
          generate an enveloped object that contains an CMS Enveloped Data object using the given provider.
 java.io.OutputStream open(java.io.OutputStream out, java.lang.String encryptionOID, java.lang.String provider)
          generate an enveloped object that contains an CMS Enveloped Data object using the given provider.
 void setBufferSize(int bufferSize)
          Set the underlying string size for encapsulated data
 
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

CAST5_CBC

public static final java.lang.String CAST5_CBC

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
Constructor Detail

CMSEnvelopedDataStreamGenerator

public CMSEnvelopedDataStreamGenerator()
base constructor
Method Detail

setBufferSize

public void setBufferSize(int bufferSize)
Set the underlying string size for encapsulated data
Parameters:
bufferSize - length of octet strings to buffer the data.

addKeyTransRecipient

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

addKeyTransRecipient

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

addKEKRecipient

public void addKEKRecipient(javax.crypto.SecretKey key,
                            byte[] keyIdentifier)
                     throws java.lang.IllegalArgumentException
add a KEK recipient.

open

public java.io.OutputStream open(java.io.OutputStream out,
                                 java.lang.String encryptionOID,
                                 java.lang.String provider)
                          throws java.security.NoSuchAlgorithmException,
                                 java.security.NoSuchProviderException,
                                 CMSException,
                                 java.io.IOException
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.
Throws:
java.io.IOException -  

open

public java.io.OutputStream open(java.io.OutputStream out,
                                 java.lang.String encryptionOID,
                                 int keySize,
                                 java.lang.String provider)
                          throws java.security.NoSuchAlgorithmException,
                                 java.security.NoSuchProviderException,
                                 CMSException,
                                 java.io.IOException
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.
Throws:
java.io.IOException -  

Bouncy Castle Cryptography 1.30