Bouncy Castle Cryptography Library 1.45

## org.bouncycastle.cms
Class CMSSignedDataStreamGenerator

    java.lang.Object
      org.bouncycastle.cms.CMSSignedGenerator
          org.bouncycastle.cms.CMSSignedDataStreamGenerator

    public class CMSSignedDataStreamGenerator

extends CMSSignedGenerator

General class for generating a pkcs7-signature message stream.

A simple example of usage.

          CertStore                    certs...
          CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();

          gen.addSigner(privateKey, cert, CMSSignedDataStreamGenerator.DIGEST_SHA1, "BC");

          gen.addCertificatesAndCRLs(certs);

          OutputStream sigOut = gen.open(bOut);

          sigOut.write("Hello World!".getBytes());

          sigOut.close();

Field Summary

Fields inherited from class org.bouncycastle.cms.CMSSignedGenerator
`_certs, _crls, _digests, _signers, DATA, DIGEST_GOST3411, DIGEST_MD5, DIGEST_RIPEMD128, DIGEST_RIPEMD160, DIGEST_RIPEMD256, DIGEST_SHA1, DIGEST_SHA224, DIGEST_SHA256, DIGEST_SHA384, DIGEST_SHA512, ENCRYPTION_DSA, ENCRYPTION_ECDSA, ENCRYPTION_ECGOST3410, ENCRYPTION_GOST3410, ENCRYPTION_RSA, ENCRYPTION_RSA_PSS, rand`

Constructor Summary
`CMSSignedDataStreamGenerator()` base constructor
`CMSSignedDataStreamGenerator(java.security.SecureRandom rand)` constructor allowing specific source of randomness

Method Summary
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr, java.security.Provider sigProvider)` add a signer with extra signed/unsigned attributes.
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr, java.lang.String sigProvider)` add a signer with extra signed/unsigned attributes.
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.security.Provider sigProvider)`
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.lang.String sigProvider)`
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, java.security.Provider sigProvider)` add a signer - no attributes other than the default ones will be provided here.
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, java.lang.String sigProvider)` add a signer - no attributes other than the default ones will be provided here.
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.security.Provider sigProvider)`
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.lang.String sigProvider)`
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, java.security.Provider sigProvider)` add a signer - no attributes other than the default ones will be provided here, specifying the digest encryption algorithm.
`void` `addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, java.lang.String sigProvider)` add a signer - no attributes other than the default ones will be provided here.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr, java.security.Provider sigProvider)` add a signer with extra signed/unsigned attributes.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr, java.lang.String sigProvider)` add a signer with extra signed/unsigned attributes.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.security.Provider sigProvider)`
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.lang.String sigProvider)`
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, java.security.Provider sigProvider)` add a signer - no attributes other than the default ones will be provided here.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, java.lang.String sigProvider)` add a signer - no attributes other than the default ones will be provided here.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr, java.security.Provider sigProvider)` add a signer with extra signed/unsigned attributes and the digest encryption algorithm.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr, java.lang.String sigProvider)` add a signer with extra signed/unsigned attributes - specifying digest encryption algorithm.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.security.Provider sigProvider)`
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, java.lang.String sigProvider)`
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, java.security.Provider sigProvider)` add a signer, specifying digest encryptionOID - no attributes other than the default ones will be provided here.
`void` `addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, java.lang.String sigProvider)` add a signer, specifying the digest encryption algorithm - no attributes other than the default ones will be provided here.
`java.io.OutputStream` `open(java.io.OutputStream out)` generate a signed object that for a CMS Signed Data object using the given provider.
`java.io.OutputStream` `open(java.io.OutputStream out, boolean encapsulate)` generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data".
`java.io.OutputStream` `open(java.io.OutputStream out, boolean encapsulate, java.io.OutputStream dataOutputStream)` generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data".
`java.io.OutputStream` `open(java.io.OutputStream out, java.lang.String eContentType, boolean encapsulate)` generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature.
`java.io.OutputStream` `open(java.io.OutputStream out, java.lang.String eContentType, boolean encapsulate, java.io.OutputStream dataOutputStream)` generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature.
`void` `setBufferSize(int bufferSize)` Set the underlying string size for encapsulated data

Methods inherited from class org.bouncycastle.cms.CMSSignedGenerator
`addAttributeCertificates, addCertificatesAndCRLs, addSigners, getAttributeSet, getBaseParameters, getEncAlgorithmIdentifier, getEncOID, getGeneratedDigests`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CMSSignedDataStreamGenerator

    public CMSSignedDataStreamGenerator()

  base constructor

### CMSSignedDataStreamGenerator

    public CMSSignedDataStreamGenerator(java.security.SecureRandom rand)

  constructor allowing specific source of randomness

  Parameters:
    `rand` - instance of SecureRandom to use

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.

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String digestOID,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer - no attributes other than the default ones will be provided here.

  Throws:
    `java.security.NoSuchProviderException`
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer, specifying the digest encryption algorithm - no attributes other than the default ones will be provided here.

  Throws:
    `java.security.NoSuchProviderException`
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String digestOID,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer - no attributes other than the default ones will be provided here.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`
    `java.security.NoSuchProviderException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer, specifying digest encryptionOID - no attributes other than the default ones will be provided here.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`
    `java.security.NoSuchProviderException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String digestOID,
                          org.bouncycastle.asn1.cms.AttributeTable signedAttr,
                          org.bouncycastle.asn1.cms.AttributeTable unsignedAttr,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer with extra signed/unsigned attributes.

  Throws:
    `java.security.NoSuchProviderException`
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          org.bouncycastle.asn1.cms.AttributeTable signedAttr,
                          org.bouncycastle.asn1.cms.AttributeTable unsignedAttr,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer with extra signed/unsigned attributes - specifying digest encryption algorithm.

  Throws:
    `java.security.NoSuchProviderException`
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String digestOID,
                          org.bouncycastle.asn1.cms.AttributeTable signedAttr,
                          org.bouncycastle.asn1.cms.AttributeTable unsignedAttr,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.InvalidKeyException

  add a signer with extra signed/unsigned attributes.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          org.bouncycastle.asn1.cms.AttributeTable signedAttr,
                          org.bouncycastle.asn1.cms.AttributeTable unsignedAttr,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.InvalidKeyException

  add a signer with extra signed/unsigned attributes and the digest encryption algorithm.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.NoSuchProviderException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          java.security.cert.X509Certificate cert,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.NoSuchProviderException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String digestOID,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer - no attributes other than the default ones will be provided here.

  Throws:
    `java.security.NoSuchProviderException`
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer - no attributes other than the default ones will be provided here.

  Throws:
    `java.security.NoSuchProviderException`
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String digestOID,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer - no attributes other than the default ones will be provided here.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`
    `java.security.NoSuchProviderException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer - no attributes other than the default ones will be provided here, specifying the digest encryption algorithm.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`
    `java.security.NoSuchProviderException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String digestOID,
                          org.bouncycastle.asn1.cms.AttributeTable signedAttr,
                          org.bouncycastle.asn1.cms.AttributeTable unsignedAttr,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  add a signer with extra signed/unsigned attributes.

  Throws:
    `java.security.NoSuchProviderException`
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String digestOID,
                          org.bouncycastle.asn1.cms.AttributeTable signedAttr,
                          org.bouncycastle.asn1.cms.AttributeTable unsignedAttr,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.InvalidKeyException

  add a signer with extra signed/unsigned attributes.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.security.Provider sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.NoSuchProviderException`
    `java.security.InvalidKeyException`

### addSigner

    public void addSigner(java.security.PrivateKey key,
                          byte[] subjectKeyID,
                          java.lang.String encryptionOID,
                          java.lang.String digestOID,
                          CMSAttributeTableGenerator signedAttrGenerator,
                          CMSAttributeTableGenerator unsignedAttrGenerator,
                          java.lang.String sigProvider)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.NoSuchProviderException,
                          java.security.InvalidKeyException

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.NoSuchProviderException`
    `java.security.InvalidKeyException`

### open

    public java.io.OutputStream open(java.io.OutputStream out)
                              throws java.io.IOException

  generate a signed object that for a CMS Signed Data object using the given provider.

  Throws:
    `java.io.IOException`

### open

    public java.io.OutputStream open(java.io.OutputStream out,
                                     boolean encapsulate)
                              throws java.io.IOException

  generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data".

  Throws:
    `java.io.IOException`

### open

    public java.io.OutputStream open(java.io.OutputStream out,
                                     boolean encapsulate,
                                     java.io.OutputStream dataOutputStream)
                              throws java.io.IOException

  generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data". If dataOutputStream is non null the data being signed will be written to the stream as it is processed.

  Parameters:
    `out` - stream the CMS object is to be written to.
    `encapsulate` - true if data should be encapsulated.
    `dataOutputStream` - output stream to copy the data being signed to.
  Throws:
    `java.io.IOException`

### open

    public java.io.OutputStream open(java.io.OutputStream out,
                                     java.lang.String eContentType,
                                     boolean encapsulate)
                              throws java.io.IOException

  generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature. The content type is set according to the OID represented by the string signedContentType.

  Throws:
    `java.io.IOException`

### open

    public java.io.OutputStream open(java.io.OutputStream out,
                                     java.lang.String eContentType,
                                     boolean encapsulate,
                                     java.io.OutputStream dataOutputStream)
                              throws java.io.IOException

  generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature. The content type is set according to the OID represented by the string signedContentType.

  Parameters:
    `out` - stream the CMS object is to be written to.
    `eContentType` - OID for data to be signed.
    `encapsulate` - true if data should be encapsulated.
    `dataOutputStream` - output stream to copy the data being signed to.
  Throws:
    `java.io.IOException`

Bouncy Castle Cryptography Library 1.45