Bouncy Castle Cryptography Library 1.48

org.bouncycastle.cms
Class CMSSignedDataGenerator

java.lang.Object
  |
  +--org.bouncycastle.cms.CMSSignedGenerator
        |
        +--org.bouncycastle.cms.CMSSignedDataGenerator

public class CMSSignedDataGenerator
extends CMSSignedGenerator

general class for generating a pkcs7-signature message.

A simple example of usage, generating a detached signature.

      List             certList = new ArrayList();
      CMSTypedData     msg = new CMSProcessableByteArray("Hello world!".getBytes());

      certList.add(signCert);

      Store           certs = new JcaCertStore(certList);

      CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
      ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(signKP.getPrivate());

      gen.addSignerInfoGenerator(
                new JcaSignerInfoGeneratorBuilder(
                     new JcaDigestCalculatorProviderBuilder().setProvider("BC").build())
                     .build(sha1Signer, signCert));

      gen.addCertificates(certs);

      CMSSignedData sigData = gen.generate(msg, false);
 


Fields inherited from class org.bouncycastle.cms.CMSSignedGenerator
_signers, certs, crls, DATA, DIGEST_GOST3411, DIGEST_MD5, DIGEST_RIPEMD128, DIGEST_RIPEMD160, DIGEST_RIPEMD256, DIGEST_SHA1, DIGEST_SHA224, DIGEST_SHA256, DIGEST_SHA384, DIGEST_SHA512, digests, ENCRYPTION_DSA, ENCRYPTION_ECDSA, ENCRYPTION_ECGOST3410, ENCRYPTION_GOST3410, ENCRYPTION_RSA, ENCRYPTION_RSA_PSS, rand, signerGens
 
Constructor Summary
CMSSignedDataGenerator()
          base constructor
CMSSignedDataGenerator(java.security.SecureRandom rand)
          constructor allowing specific source of randomness
 
Method Summary
 void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID)
          Deprecated. use addSignerInfoGenerator
 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)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID)
          Deprecated. use addSignerInfoGenerator
 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)
          Deprecated. use addSignerInfoGenerator
 void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen)
          Deprecated. use addSignerInfoGenerator
 CMSSignedData generate(CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider)
          Deprecated. use generate(CMSTypedData, boolean)
 CMSSignedData generate(CMSProcessable content, boolean encapsulate, java.lang.String sigProvider)
          Deprecated. use generate(CMSTypedData, boolean)
 CMSSignedData generate(CMSProcessable content, java.security.Provider sigProvider)
          Deprecated. use generate() method not taking provider.
 CMSSignedData generate(CMSProcessable content, java.lang.String sigProvider)
          Deprecated. use generate() method not taking provider.
 CMSSignedData generate(CMSTypedData content)
           
 CMSSignedData generate(CMSTypedData content, boolean encapsulate)
           
 CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider)
          Deprecated. use generate(CMSTypedData, boolean)
 CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider, boolean addDefaultAttributes)
          Similar method to the other generate methods.
 CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.lang.String sigProvider)
          Deprecated. use generate(CMSTypedData, boolean)
 CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.lang.String sigProvider, boolean addDefaultAttributes)
          Deprecated. use generate(CMSTypedData, boolean)
 SignerInformationStore generateCounterSigners(SignerInformation signer)
          generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.
 SignerInformationStore generateCounterSigners(SignerInformation signer, java.security.Provider sigProvider)
          Deprecated. use generateCounterSigners(SignerInformation)
 SignerInformationStore generateCounterSigners(SignerInformation signer, java.lang.String sigProvider)
          Deprecated. use generateCounterSigners(SignerInformation)
 
Methods inherited from class org.bouncycastle.cms.CMSSignedGenerator
addAttributeCertificates, addAttributeCertificates, addCertificates, addCertificatesAndCRLs, addCRLs, addSignerInfoGenerator, addSigners, getAttributeSet, getBaseParameters, getEncOID, getGeneratedDigests
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMSSignedDataGenerator

public CMSSignedDataGenerator()
base constructor

CMSSignedDataGenerator

public CMSSignedDataGenerator(java.security.SecureRandom rand)
constructor allowing specific source of randomness
Parameters:
rand - instance of SecureRandom to use
Method Detail

addSigner

public void addSigner(java.security.PrivateKey key,
                      java.security.cert.X509Certificate cert,
                      java.lang.String digestOID)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer - no attributes other than the default ones will be provided here.
Parameters:
key - signing key to use
cert - certificate containing corresponding public key
digestOID - digest algorithm OID

addSigner

public void addSigner(java.security.PrivateKey key,
                      java.security.cert.X509Certificate cert,
                      java.lang.String encryptionOID,
                      java.lang.String digestOID)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer, specifying the digest encryption algorithm to use - no attributes other than the default ones will be provided here.
Parameters:
key - signing key to use
cert - certificate containing corresponding public key
encryptionOID - digest encryption algorithm OID
digestOID - digest algorithm OID

addSigner

public void addSigner(java.security.PrivateKey key,
                      byte[] subjectKeyID,
                      java.lang.String digestOID)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

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

addSigner

public void addSigner(java.security.PrivateKey key,
                      byte[] subjectKeyID,
                      java.lang.String encryptionOID,
                      java.lang.String digestOID)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

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

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)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer with extra signed/unsigned attributes.
Parameters:
key - signing key to use
cert - certificate containing corresponding public key
digestOID - digest algorithm OID
signedAttr - table of attributes to be included in signature
unsignedAttr - table of attributes to be included as unsigned

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)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer, specifying the digest encryption algorithm, with extra signed/unsigned attributes.
Parameters:
key - signing key to use
cert - certificate containing corresponding public key
encryptionOID - digest encryption algorithm OID
digestOID - digest algorithm OID
signedAttr - table of attributes to be included in signature
unsignedAttr - table of attributes to be included as unsigned

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)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer with extra signed/unsigned attributes.
Parameters:
key - signing key to use
subjectKeyID - subjectKeyID of corresponding public key
digestOID - digest algorithm OID
signedAttr - table of attributes to be included in signature
unsignedAttr - table of attributes to be included as unsigned

addSigner

public void addSigner(java.security.PrivateKey key,
                      byte[] subjectKeyID,
                      java.lang.String encryptionOID,
                      java.lang.String digestOID,
                      org.bouncycastle.asn1.cms.AttributeTable signedAttr,
                      org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer, specifying the digest encryption algorithm, with extra signed/unsigned attributes.
Parameters:
key - signing key to use
subjectKeyID - subjectKeyID of corresponding public key
encryptionOID - digest encryption algorithm OID
digestOID - digest algorithm OID
signedAttr - table of attributes to be included in signature
unsignedAttr - table of attributes to be included as unsigned

addSigner

public void addSigner(java.security.PrivateKey key,
                      java.security.cert.X509Certificate cert,
                      java.lang.String digestOID,
                      CMSAttributeTableGenerator signedAttrGen,
                      CMSAttributeTableGenerator unsignedAttrGen)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer with extra signed/unsigned attributes based on generators.

addSigner

public void addSigner(java.security.PrivateKey key,
                      java.security.cert.X509Certificate cert,
                      java.lang.String encryptionOID,
                      java.lang.String digestOID,
                      CMSAttributeTableGenerator signedAttrGen,
                      CMSAttributeTableGenerator unsignedAttrGen)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer, specifying the digest encryption algorithm, with extra signed/unsigned attributes based on generators.

addSigner

public void addSigner(java.security.PrivateKey key,
                      byte[] subjectKeyID,
                      java.lang.String digestOID,
                      CMSAttributeTableGenerator signedAttrGen,
                      CMSAttributeTableGenerator unsignedAttrGen)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer with extra signed/unsigned attributes based on generators.

addSigner

public void addSigner(java.security.PrivateKey key,
                      byte[] subjectKeyID,
                      java.lang.String encryptionOID,
                      java.lang.String digestOID,
                      CMSAttributeTableGenerator signedAttrGen,
                      CMSAttributeTableGenerator unsignedAttrGen)
               throws java.lang.IllegalArgumentException
Deprecated. use addSignerInfoGenerator

add a signer, including digest encryption algorithm, with extra signed/unsigned attributes based on generators.

generate

public CMSSignedData generate(CMSProcessable content,
                              java.lang.String sigProvider)
                       throws java.security.NoSuchAlgorithmException,
                              java.security.NoSuchProviderException,
                              CMSException
Deprecated. use generate() method not taking provider.

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

generate

public CMSSignedData generate(CMSProcessable content,
                              java.security.Provider sigProvider)
                       throws java.security.NoSuchAlgorithmException,
                              CMSException
Deprecated. use generate() method not taking provider.

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

generate

public CMSSignedData generate(java.lang.String eContentType,
                              CMSProcessable content,
                              boolean encapsulate,
                              java.lang.String sigProvider)
                       throws java.security.NoSuchAlgorithmException,
                              java.security.NoSuchProviderException,
                              CMSException
Deprecated. use generate(CMSTypedData, boolean)

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.

generate

public CMSSignedData generate(java.lang.String eContentType,
                              CMSProcessable content,
                              boolean encapsulate,
                              java.security.Provider sigProvider)
                       throws java.security.NoSuchAlgorithmException,
                              CMSException
Deprecated. use generate(CMSTypedData, boolean)

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.

generate

public CMSSignedData generate(java.lang.String eContentType,
                              CMSProcessable content,
                              boolean encapsulate,
                              java.lang.String sigProvider,
                              boolean addDefaultAttributes)
                       throws java.security.NoSuchAlgorithmException,
                              java.security.NoSuchProviderException,
                              CMSException
Deprecated. use generate(CMSTypedData, boolean)

Similar method to the other generate methods. The additional argument addDefaultAttributes indicates whether or not a default set of signed attributes need to be added automatically. If the argument is set to false, no attributes will get added at all.

generate

public CMSSignedData generate(java.lang.String eContentType,
                              CMSProcessable content,
                              boolean encapsulate,
                              java.security.Provider sigProvider,
                              boolean addDefaultAttributes)
                       throws java.security.NoSuchAlgorithmException,
                              CMSException
Similar method to the other generate methods. The additional argument addDefaultAttributes indicates whether or not a default set of signed attributes need to be added automatically. If the argument is set to false, no attributes will get added at all.

generate

public CMSSignedData generate(CMSProcessable content,
                              boolean encapsulate,
                              java.lang.String sigProvider)
                       throws java.security.NoSuchAlgorithmException,
                              java.security.NoSuchProviderException,
                              CMSException
Deprecated. use generate(CMSTypedData, boolean)

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".

generate

public CMSSignedData generate(CMSProcessable content,
                              boolean encapsulate,
                              java.security.Provider sigProvider)
                       throws java.security.NoSuchAlgorithmException,
                              CMSException
Deprecated. use generate(CMSTypedData, boolean)

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".

generate

public CMSSignedData generate(CMSTypedData content)
                       throws CMSException

generate

public CMSSignedData generate(CMSTypedData content,
                              boolean encapsulate)
                       throws CMSException

generateCounterSigners

public SignerInformationStore generateCounterSigners(SignerInformation signer,
                                                     java.security.Provider sigProvider)
                                              throws java.security.NoSuchAlgorithmException,
                                                     CMSException
Deprecated. use generateCounterSigners(SignerInformation)

generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.
Parameters:
signer - the signer to be countersigned
sigProvider - the provider to be used for counter signing.
Returns:
a store containing the signers.

generateCounterSigners

public SignerInformationStore generateCounterSigners(SignerInformation signer,
                                                     java.lang.String sigProvider)
                                              throws java.security.NoSuchAlgorithmException,
                                                     java.security.NoSuchProviderException,
                                                     CMSException
Deprecated. use generateCounterSigners(SignerInformation)

generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.
Parameters:
signer - the signer to be countersigned
sigProvider - the provider to be used for counter signing.
Returns:
a store containing the signers.

generateCounterSigners

public SignerInformationStore generateCounterSigners(SignerInformation signer)
                                              throws CMSException
generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.
Parameters:
signer - the signer to be countersigned
Returns:
a store containing the signers.

Bouncy Castle Cryptography Library 1.48