| 
 | IAIK CMS/SMIME Toolkit API Documentation Version 6.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectiaik.cms.SignedDataStream
iaik.smime.SMimeSigned
public class SMimeSigned
This class represents the "CMS SignedData object carrying" part of a S/MIME signed message.
 This class extends the SignedDataStream class of 
 the iaik.cms and may be used for creating and parsing 
 CMS SignedData objects 
 that are (to be) wrapped into a ContentInfo structure.
 
 The steps for creating a SMimeSigned object and writing it to a stream may
 be summarized as follows (notice that the usage in general complies with that
 of the parent SignedDataStream, but is adopted to the specific
 requirements of the S/MIME protocol):
 
SMimeSigned object thereby supplying the raw data
     to be signed as input stream and specifying the transmission mode to be used
     (either SMimeSigned.IMPLICIT for including the content as used
     for an application/pkcs7-mime message or SMimeSigned.EXPLICIT for
     transmitting the content outside the SignedData object):
     
     InputStream data_stream data_stream = ...;
     int mode = ...;
     SMimeSigned signed = new SMimeSigned(data_stream, mode);
     
 setCertificates(Certificate[]) method:
     
     signed.setCertificates(certificates);
     
 addSigner(PrivateKey, IssuerAndSerialNumber) method thereby supplying signer
     private key and IssuerAndSerialNumer of the signer certificate (note that when 
     adding a Signer using this method, digest and signature algorithm will be
     automatically calculated from the private key algorithm. If you want to explicitly set
     digest/signature algorithm you may call some alternative addSigner method):
     
     PrivateKey signerPrivateKey = ...;
     X509Certificate signerCertificate = ...;
     signed.addSigner(signerPrivateKey, new IssuerAndSerialNumber(signerCertificate));
     
     The addSigner method creates an iaik.cms.SignerInfo
     object from the given information and sets the SignerInfo for the SMimeSigned
     SignedData object. Depending on which addSigner method is used, a
     set of signed standard attributes is added to the SignerInfo, as proposed by CMS and S/MIME.
     The following attributes are added, regardless of which addSigner method
     is used:
     
     When calling an addSigner and specifying the certificate of the signer, an ESS SigningCertificate
     or SigningCertificateV2 attribute is added identifying the certificate
     of the signer.
     
     When calling an addSigner method where the encryption certificate of the signer 
     is identified or specified an SMIMEEncryptionKeyPreference attribute and (optionally, 
     if required) an a private MS attribute ("1.3.6.1.4.1.311.16.4") are added, both 
     identifying the encryption certificate of the signer.
 
     if (mode == SMimeSigned.EXPLICIT) {
       InputStream data_is = signed.getInputStream();
       byte[] buf = new byte[2048];
       int r;
       while ((r = data_is.read(buf)) > 0) {
         // do something useful
       }
     }
     
     When using the implicit mode, do not explicitly read data from the input stream
     at all! This will be done automatically during the last step when performing the encoding.
     
writeTo method for wrapping
     the SignedData object into a ContentInfo and writing it BER encoded to an output
     stream.
     
     signed.writeTo(output_stream);
     
 
 On the recipient side it also has to be distinguished between IMPLICIT and EXPLICIT
 mode for parsing a received SMimeSigned message. When operating in IMPLICIT mode,
 the raw data is included in the received object, and so the parsing immediately
 may be performed when creating a SMimeSigned object from the BER encoded
 SMimeSigned message by calling the SMimeSigned(InputStream is) constructor. On the other side, when
 the raw data has been transmitted outside the signature (EXPLICIT mode), the
 SMimeSigned(InputStream data_is, AlgorithmID[] hashAlgorithms) constructor
 has to be used for initializing the new SMimeSigned object with raw data and
 hash algorithms to be used for digest computation; and the decoding has to be
 performed explicitly by calling the decode method.
 The initialization is necessary for preparing the digest computation on the raw
 data. Later, during signature verification the digest value computaion is
 finished and the result is compared against the hash value resulting from
 decrypting the encrypted digest with the signer public key.
 
 The individual steps necessary for parsing a received SMimeSigned message and
 verifying the signature may be summarized as follows:
 
SMimeSigned(InputStream is)
     constructor for creating a SMimeSigned object and implicitly performing the
     decoding:
     
     SMimeSigned signed = new SMimeSigned(encoded_stream);
     
     On the other hand, if the BER encoding represents an
     explicit SMimeSigned object, use the
     SMimeSigned(InputStream data_is, AlgorithmID[] hashAlgorithms)
     constructor for initializing a new SMimeSigned object with raw data and
     digest algorithms for hash computation (e.g., one signer):
     
     AlgorithmID[] algID = { AlgorithmID.sha256 };
     SMimeSigned signed = new SMimeSigned(data_is, algIDs);
     
 
     InputStream dataIs = signed.getInputStream();
     byte[] buf = new byte[2048];
     int r;
     while ((r = dataIs.read(buf)) > 0) {
       // do something useful
     }
     
 decode method:
     
     signed.decode(encoded_stream);
     
 
      try {
         X509Certificate cert = signed.verify();
         System.out.println("Signature OK from: "+cert.getSubjectDN());
      } catch (SignatureException ex) {
          System.out.println("Signature ERROR!");
       }
     
 
SignedDataStream, 
SignerInfo, 
SignedContent| Field Summary | 
|---|
| Fields inherited from class iaik.cms.SignedDataStream | 
|---|
| blockSize_, certSet_, contentType_, crls_, encapContentInfo_, EXPLICIT, IMPLICIT, inputStream_, mode_, securityProvider_, signerInfos_, thisObject_, version_ | 
| Constructor Summary | |
|---|---|
| SMimeSigned(java.io.InputStream is)Reads a SMimeSigned message from an InputStream. | |
| SMimeSigned(java.io.InputStream is,
            iaik.asn1.structures.AlgorithmID[] hashAlgorithm)Creates a new SMimeSigned from an InputStream holding the signed data and an algorithm specifying the hash algorithm to use for digesting. | |
| SMimeSigned(java.io.InputStream is,
            int mode)Creates a SMimeSigned object from an input stream which supplies the data to be signed. | |
| SMimeSigned(java.io.InputStream is,
            iaik.asn1.ObjectID contentType,
            int mode)Creates a SMimeSigned object from an input stream which supplies the data to be signed. | |
| Method Summary | |
|---|---|
|  void | addSigner(java.security.PrivateKey privateKey,
          IssuerAndSerialNumber signer)Signs this message using the supplied signer private key. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          IssuerAndSerialNumber signer,
          iaik.asn1.structures.AlgorithmID digestAlgorithm,
          iaik.asn1.structures.AlgorithmID signatureAlgorithm)Signs this message using the supplied signer private key with the given signature algorithm. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          IssuerAndSerialNumber signer,
          iaik.asn1.structures.AlgorithmID digestAlgorithm,
          iaik.asn1.structures.AlgorithmID signatureAlgorithm,
          iaik.asn1.structures.Attribute[] signedAttributes)Signs this message using the supplied signer private key with the given signature algorithm. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          IssuerAndSerialNumber signer,
          iaik.asn1.structures.AlgorithmID digestAlgorithm,
          iaik.asn1.structures.AlgorithmID signatureAlgorithm,
          CertificateIdentifier encryptionCertId,
          boolean includeEncryptionCertIDForMSOE)Signs this message using the supplied signer private key with the given signature algorithm. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          IssuerAndSerialNumber signer,
          CertificateIdentifier encryptionCertId,
          boolean includeEncryptionCertIDForMSOE)Signs this message using the supplied signer private key. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          iaik.x509.X509Certificate signerCert,
          iaik.asn1.structures.AlgorithmID digestAlgorithm,
          iaik.asn1.structures.AlgorithmID signatureAlgorithm,
          iaik.asn1.structures.Attribute[] signedAttributes)Signs this message using the supplied signer private key with the given signature algorithm. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          iaik.x509.X509Certificate signerCert,
          iaik.asn1.structures.AlgorithmID digestAlgorithm,
          iaik.asn1.structures.AlgorithmID signatureAlgorithm,
          CertificateIdentifier encryptionCertId,
          boolean includeEncryptionCertIDForMSOE)Signs this message using the supplied signer private key with the given signature algorithm. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          iaik.x509.X509Certificate signerCert,
          iaik.asn1.structures.AlgorithmID digestAlgorithm,
          iaik.asn1.structures.AlgorithmID signatureAlgorithm,
          iaik.x509.X509Certificate encryptionCert,
          boolean includeEncryptionCertIDForMSOE)Signs this message using the supplied signer private key with the given signature algorithm. | 
|  void | addSigner(java.security.PrivateKey privateKey,
          iaik.x509.X509Certificate signerCert,
          iaik.x509.X509Certificate encryptionCert,
          boolean includeEncryptionCertIDForMSOE)Signs this message using the supplied signer private key. | 
|  int | getMode()Returns the mode of this message. | 
|  iaik.asn1.ASN1Object | toASN1Object(int blockSize)Returns the CMS SignedData object as an ASN1Object wrapped into a ContentInfo. | 
|  java.lang.String | toString()Returns a string representation of this message. | 
|  iaik.x509.X509Certificate | verify()Verifies the signature and returns the certificate of the signer (i.e. | 
|  void | verify(java.security.PublicKey publicKey)Verifies the signature of the signer (i.e. the signer with the SignerInfo at index 0) with the provided public key. | 
|  void | writeTo(java.io.OutputStream os)Writes this SMimeSigned object to the supplied output stream. | 
|  void | writeTo(java.io.OutputStream os,
        int blockSize)Writes this SMimeSigned object to the supplied output stream. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
public SMimeSigned(java.io.InputStream is,
                   int mode)
There are two possible modes:
is - a stream supplying the data to signmode - IMPLICIT if the message shall be included in the DER encoding,
             EXPLICIT otherwise
public SMimeSigned(java.io.InputStream is,
                   iaik.asn1.ObjectID contentType,
                   int mode)
There are two possible modes:
is - a stream supplying the data to signcontentType - the contentType for the inherent EncapsulatedContentInfomode - IMPLICIT if the message shall be included in the DER encoding,
             EXPLICIT otherwise
public SMimeSigned(java.io.InputStream is,
                   iaik.asn1.structures.AlgorithmID[] hashAlgorithm)
            throws java.io.IOException
 This constructor shall be used to process an already existing EXPLICIT
 SMimeSigned object. It will setup a DigestInputStream where the signed data
 is piped through. The new InputStream can be retrieved using the method
 getInputStream for reading the data and thereby
 piping it through a digest stream for hash calculation.
 
 For subsequently processing the DER encoded SMimeSigned object, use method
 decode(InpuStream), e.g.:
 
 AlgorithmID[] algID = { AlgorithmID.sha256 };
 SMimeSigned signed = new SMimeSigned(data_is, algIDs);
 InputStream dataIs = signed.getInputStream();
 byte[] buf = new byte[2048];
 int r;
 while ((r = dataIs.read(buf)) > 0) {
   // do something useful
 }
 signed.decode(encoded_stream);
 
is - the InputStream holding the raw data supplied by other means, i.e. the
        first part of a multipart/signed messagehashAlgorithm - the hash algorithm(s) used for digesting the signed data;
        supplied as array of hash algorithms
java.io.IOException - if an I/O error occurs or there is no implementation for the specified
            hash algorithm
public SMimeSigned(java.io.InputStream is)
            throws java.io.IOException
 Do not use this constructor for supplying the content data
 to be signed. This constructor may be used by the recipient for parsing an
 already exisiting SMimeSigned object, supplied as DER encoding
 from an input stream, that may have been created by means of the
 writeTo method.
 
 Use the SMimeSigned(InputStream data_is, int mode)
 constructor for supplying the content data to be signed when creating a
 SMimeSigned object.
 
 This constructor only shall be used for decoding a SMimeSigned object with
 included raw data (implicit mode).
 
 To initialize a SMimeSigned object for parsing an explicit message where the
 raw data is not included, use the
 SMimeSigned(InputStream is, AlgorithmID[] hashAlgorithms)
 constructor, and perform the decoding explicitly by calling the
 decode method.
is - the input stream where the DER encoded message shall be read from
java.io.IOException - if an I/O error or parsing problem occurs| Method Detail | 
|---|
public void addSigner(java.security.PrivateKey privateKey,
                      IssuerAndSerialNumber signer)
               throws java.security.NoSuchAlgorithmException
addSigner method).
 issuerAndSerialNumber field of the
 SignerInfo structure of the inherent SignedData object. This field is used
 for specifying the signer certificate by issuer distinguished name and
 issuer-specific serial number.
 
 When creating the SignerInfo object for the signer, the
 following attributes are set for the SignerInfo structure:
 
privateKey - the private key which shall be used for signingsigner - IssuerAndSerialNumber from the certificate which must be used
        for verifying the signature
java.security.NoSuchAlgorithmException - if no implementation of the required
                                     algorithms is available.
public void addSigner(java.security.PrivateKey privateKey,
                      IssuerAndSerialNumber signer,
                      CertificateIdentifier encryptionCertId,
                      boolean includeEncryptionCertIDForMSOE)
               throws java.security.NoSuchAlgorithmException
addSigner method).
 issuerAndSerialNumber field of the
 SignerInfo structure of the inherent SignedData object. This field is used
 for specifying the signer certificate by issuer distinguished name and
 issuer-specific serial number.
 
 When creating the SignerInfo object for the signer, the
 following attributes are set for the SignerInfo structure:
 
encryptionCertID is not nullencryptionCertID is not null and 
        includeEncryptionCertIDForMSOE allowing MSOE to recognize
        the encryption certificate is different certs are used for signing
        and encryption
    
 Inclusion of a special private Microsoft signed attribute (type: 1.3.6.1.4.1.311.16.4)
 for identifying the encryption certificate of the sender by IssuerAndSerialNumber
 might be useful to tell Outlook Express the encryption certificate to be used if
 separate certificates are used for signing and encryption. If you want to include
 this attribute, set includeEncryptionCertIDForMSOE to true
 and supply the IssuerAndSerialNumber of the encryption certificate ("encryptionCertId").
 
privateKey - the private key which shall be used for signingsigner - IssuerAndSerialNumber from the certificate which must be used
        for verifying the signatureencryptionCertId - the identifier of the encryption certificate of the
        sender by the SMIMEEncryptionKeyPreference attribute (or 
        null if signing and encryption cert are the
        same or no encryption certificate shall be indicated)includeEncryptionCertIDForMSOE - if true and an 
        encryptionCertID of type IssuerAndSerialNumber is provided,
        a private MS attribute will be included allowing MSOE to recognize
        the encryption cert of the signer if using different certs for
        signing/encryption
java.security.NoSuchAlgorithmException - if no implementation of the required
                                     algorithms is available.
public void addSigner(java.security.PrivateKey privateKey,
                      iaik.x509.X509Certificate signerCert,
                      iaik.x509.X509Certificate encryptionCert,
                      boolean includeEncryptionCertIDForMSOE)
               throws java.security.NoSuchAlgorithmException
addSigner method).
 
 When creating the SignerInfo object for the signer, the
 following attributes are set for the SignerInfo structure:
 
encryptionCertID is not nullencryptionCertID is not null and 
        includeEncryptionCertIDForMSOE allowing MSOE to recognize
        the encryption certificate is different certs are used for signing
        and encryption
    signerCert is not
     null
 Inclusion of a special private Microsoft signed attribute (type: 1.3.6.1.4.1.311.16.4)
 for identifying the encryption certificate of the sender by IssuerAndSerialNumber
 might be useful to tell Outlook Express the encryption certificate to be used if
 separate certificates are used for signing and encryption. If you want to include
 this attribute, set includeEncryptionCertIDForMSOE to true
 and supply the IssuerAndSerialNumber of the encryption certificate ("encryptionCertId").
 
privateKey - the private key which shall be used for signingsignerCert - the certificate of the signer which must be used
        for verifying the signatureencryptionCert - the encryption certificate of the
        sender to be identified by the SMIMEEncryptionKeyPreference attribute (or 
        null if signing and encryption cert are the
        same or no encryption certificate shall be indicated)includeEncryptionCertIDForMSOE - if true and an 
        encryptionCertID of type IssuerAndSerialNumber is provided,
        a private MS attribute will be included allowing MSOE to recognize
        the encryption cert of the signer if using different certs for
        signing/encryption
java.security.NoSuchAlgorithmException - if no implementation of the required
                                     algorithms is available.
public void addSigner(java.security.PrivateKey privateKey,
                      IssuerAndSerialNumber signer,
                      iaik.asn1.structures.AlgorithmID digestAlgorithm,
                      iaik.asn1.structures.AlgorithmID signatureAlgorithm)
               throws java.security.NoSuchAlgorithmException
 Calling this method also initializes the digest computation by wrapping a
 digest stream for the digest algorithm around the data carrying input
 stream. When creating the SignerInfo object for the signer, the
 following attributes are set for the SignerInfo structure:
 
privateKey - the private key which shall be used for signingsigner - IssuerAndSerialNumber from the certificate which must be used
        for verifying the signaturedigestAlgorithm - the digest algorithmsignatureAlgorithm - the signature algorithm
java.security.NoSuchAlgorithmException - if no implementation of the requested
            message digest algorithm is available
public void addSigner(java.security.PrivateKey privateKey,
                      IssuerAndSerialNumber signer,
                      iaik.asn1.structures.AlgorithmID digestAlgorithm,
                      iaik.asn1.structures.AlgorithmID signatureAlgorithm,
                      CertificateIdentifier encryptionCertId,
                      boolean includeEncryptionCertIDForMSOE)
               throws java.security.NoSuchAlgorithmException
 Calling this method also initializes the digest computation by wrapping a
 digest stream for the digest algorithm around the data carrying input
 stream. When creating the SignerInfo object for the signer, the
 following attributes are set for the SignerInfo structure:
 
encryptionCertID is not nullencryptionCertID is not null and 
        includeEncryptionCertIDForMSOE allowing MSOE to recognize
        the encryption certificate is different certs are used for signing
        and encryption
    
 Inclusion of a special private Microsoft signed attribute (type: 1.3.6.1.4.1.311.16.4)
 for identifying the encryption certificate of the sender by IssuerAndSerialNumber
 might be useful to tell Outlook Express the encryption certificate to be used if
 separate certificates are used for signing and encryption. If you want to include
 this attribute, set includeEncryptionCertIDForMSOE to true
 and supply the IssuerAndSerialNumber of the encryption certificate ("encryptionCertId").
privateKey - the private key which shall be used for signingsigner - IssuerAndSerialNumber from the certificate which must be used
        for verifying the signaturedigestAlgorithm - the digest algorithmsignatureAlgorithm - the signature algorithmencryptionCertId - the identifier of the encryption certificate of the
        sender by the SMIMEEncryptionKeyPreference attribute (or 
        null if signing and encryption cert are the
        same or no encryption certificate shall be indicated)includeEncryptionCertIDForMSOE - if true and an 
        encryptionCertID of type IssuerAndSerialNumber is provided,
        a private MS attribute will be included allowing MSOE to recognize
        the encryption cert of the signer if using different certs for
        signing/encryption
java.security.NoSuchAlgorithmException - if no implementation of the requested
            message digest algorithm is available
public void addSigner(java.security.PrivateKey privateKey,
                      iaik.x509.X509Certificate signerCert,
                      iaik.asn1.structures.AlgorithmID digestAlgorithm,
                      iaik.asn1.structures.AlgorithmID signatureAlgorithm,
                      CertificateIdentifier encryptionCertId,
                      boolean includeEncryptionCertIDForMSOE)
               throws java.security.NoSuchAlgorithmException
 Calling this method also initializes the digest computation by wrapping a
 digest stream for the digest algorithm around the data carrying input
 stream. When creating the SignerInfo object for the signer, the
 following attributes are set for the SignerInfo structure:
 
encryptionCertID is not nullencryptionCertID is not null and 
        includeEncryptionCertIDForMSOE allowing MSOE to recognize
        the encryption certificate is different certs are used for signing
        and encryption
    signerCert is not
     null
 Inclusion of a special private Microsoft signed attribute (type: 1.3.6.1.4.1.311.16.4)
 for identifying the encryption certificate of the sender by IssuerAndSerialNumber
 might be useful to tell Outlook Express the encryption certificate to be used if
 separate certificates are used for signing and encryption. If you want to include
 this attribute, set includeEncryptionCertIDForMSOE to true
 and supply the IssuerAndSerialNumber of the encryption certificate ("encryptionCertId").
privateKey - the private key which shall be used for signingsignerCert - the certificate of the signer which must be used
        for verifying the signaturedigestAlgorithm - the digest algorithmsignatureAlgorithm - the signature algorithmencryptionCertId - the identifier of the encryption certificate of the
        sender by the SMIMEEncryptionKeyPreference attribute (or 
        null if signing and encryption cert are the
        same or no encryption certificate shall be indicated)includeEncryptionCertIDForMSOE - if true and an 
        encryptionCertID of type IssuerAndSerialNumber is provided,
        a private MS attribute will be included allowing MSOE to recognize
        the encryption cert of the signer if using different certs for
        signing/encryption
java.security.NoSuchAlgorithmException - if no implementation of the requested
            message digest algorithm is available
public void addSigner(java.security.PrivateKey privateKey,
                      iaik.x509.X509Certificate signerCert,
                      iaik.asn1.structures.AlgorithmID digestAlgorithm,
                      iaik.asn1.structures.AlgorithmID signatureAlgorithm,
                      iaik.x509.X509Certificate encryptionCert,
                      boolean includeEncryptionCertIDForMSOE)
               throws java.security.NoSuchAlgorithmException
 Calling this method also initializes the digest computation by wrapping a
 digest stream for the digest algorithm around the data carrying input
 stream. When creating the SignerInfo object for the signer, the
 following attributes are set for the SignerInfo structure:
 
encryptionCertID is not nullencryptionCertID is not null and 
        includeEncryptionCertIDForMSOE allowing MSOE to recognize
        the encryption certificate is different certs are used for signing
        and encryption
    signerCert is not
     null
 Inclusion of a special private Microsoft signed attribute (type: 1.3.6.1.4.1.311.16.4)
 for identifying the encryption certificate of the sender by IssuerAndSerialNumber
 might be useful to tell Outlook Express the encryption certificate to be used if
 separate certificates are used for signing and encryption. If you want to include
 this attribute, set includeEncryptionCertIDForMSOE to true
 and supply the IssuerAndSerialNumber of the encryption certificate ("encryptionCertId").
privateKey - the private key which shall be used for signingsignerCert - the certificate of the signer which must be used
        for verifying the signaturedigestAlgorithm - the digest algorithmsignatureAlgorithm - the signature algorithmencryptionCert - the encryption certificate of the
        sender to be -- if not null -- identified by the SMIMEEncryptionKeyPreference 
        attribute (or null if signing and encryption cert are the
        same or no encryption certificate shall be indicated)includeEncryptionCertIDForMSOE - if true and an 
        encryptionCertID of type IssuerAndSerialNumber is provided,
        a private MS attribute will be included allowing MSOE to recognize
        the encryption cert of the signer if using different certs for
        signing/encryption
java.security.NoSuchAlgorithmException - if no implementation of the requested
            message digest algorithm is available
public void addSigner(java.security.PrivateKey privateKey,
                      IssuerAndSerialNumber signer,
                      iaik.asn1.structures.AlgorithmID digestAlgorithm,
                      iaik.asn1.structures.AlgorithmID signatureAlgorithm,
                      iaik.asn1.structures.Attribute[] signedAttributes)
               throws java.security.NoSuchAlgorithmException
Calling this method also initializes the digest computation by wrapping a digest stream for the digest algorithm around the data carrying input stream.
 Please note that no signed attributes are created by this method (as done by the
 other addSigner methods. This method sets the supplied attributes
 for the SignerInfo to be created for the signer.
privateKey - the private key which shall be used for signingsigner - IssuerAndSerialNumber from the certificate which must be used
        for verifying the signaturedigestAlgorithm - the digest algorithmsignatureAlgorithm - the signature algorithmsignedAttributes - any signed attributes to be set
java.security.NoSuchAlgorithmException - if no implementation of the requested
            message digest algorithm is available
public void addSigner(java.security.PrivateKey privateKey,
                      iaik.x509.X509Certificate signerCert,
                      iaik.asn1.structures.AlgorithmID digestAlgorithm,
                      iaik.asn1.structures.AlgorithmID signatureAlgorithm,
                      iaik.asn1.structures.Attribute[] signedAttributes)
               throws java.security.NoSuchAlgorithmException
Calling this method also initializes the digest computation by wrapping a digest stream for the digest algorithm around the data carrying input stream.
 Please note that no signed attributes are created by this method (as done by the
 other addSigner methods. This method sets the supplied attributes
 for the SignerInfo to be created for the signer.
privateKey - the private key which shall be used for signingsignerCert - the certificate of the signer which must be used
        for verifying the signaturedigestAlgorithm - the digest algorithmsignatureAlgorithm - the signature algorithmsignedAttributes - any signed attributes to be set
java.security.NoSuchAlgorithmException - if no implementation of the requested
            message digest algorithm is available
public iaik.x509.X509Certificate verify()
                                 throws CMSSignatureException
This method may be used for verifying the signature when only one signer is included.
CMSSignatureException - if this message does not verify or the signer
            certificate is not included in the message
CertificateNotFoundException - if the certificate of the signer is not included in this SignedData object
InvalidContentHashException - if the signature verification process fails because the
                                        content hash does not match to value of the included MessageDigest 
                                        attribute
InvalidSignatureValueException - if the signature verification process fails because the
                                        signature value is invalid
public void verify(java.security.PublicKey publicKey)
            throws CMSSignatureException
This method may be used for verifying the signature when only one signer is included.
publicKey - the public key of the signer to verify the message
CMSSignatureException - if this message does not verify
InvalidContentHashException - if the signature verification process fails because the
                                        content hash does not match to value of the included MessageDigest 
                                        attribute
InvalidSignatureValueException - if the signature verification process fails because the
                                        signature value is invalidpublic int getMode()
getMode in class SignedDataStream
public iaik.asn1.ASN1Object toASN1Object(int blockSize)
                                  throws CMSException
toASN1Object in class SignedDataStreamblockSize - the block size for using block encoding
CMSException - if the ASN1Object could not be created
public void writeTo(java.io.OutputStream os)
             throws java.io.IOException
writeTo in class SignedDataStreamos - the output stream to which this SMimeSigned shall be written
java.io.IOException - if an error occurs while writing to the stream
public void writeTo(java.io.OutputStream os,
                    int blockSize)
             throws java.io.IOException
blockSize parameter indicates the block size to
 be used for performimg block encoding.
writeTo in class SignedDataStreamos - the output stream to which this SMimeSigned shall be writtenblockSize - the block size for performing block encoding
java.io.IOException - if an error occurs while writing to the streampublic java.lang.String toString()
toString in class SignedDataStream| 
 | IAIK CMS/SMIME Toolkit API Documentation Version 6.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
|   | v6.1 (c) 2002 IAIK, (c) 2003 - 2025 SIC |   |