Creating MultipartSigned Entities Creating Digital Envelopes

6-12 Oracle Fusion Middleware Reference for Oracle Security Developer Tools

6.3.3.3 Creating MultipartSigned Entities

The SmimeMultipartSigned class provides an alternative way to create signed messages. These messages use the multipartsigned mime type instead of applicationpkcs7-mime. The advantage is that the content of the resulting message is readable with non-MIME enabled mail clients, although such clients will not, of course, be able to verify the signature. Creating a multi-partsigned message is slightly different from creating a signed message. For example, to send a multi-partsigned text message: create the content text as a MIME body part MimeBodyPart bp = new MimeBodyPart; bp.setTextExample multipartsigned message.; the constructor takes the signature algorithm SmimeMultipartSigned sig = new SmimeMultipartSignedbp, AlgID.sha1; sign the content sig.addSignaturesignerKey, signerCert; place the content in a MIME message MimeMessage msg = new MimeMessage; msg.setContentsig, sig.generateContentType; The reason for identifying the message digest in the SmimeMultipartSigned constructor is that, unlike the case of applicationpkcs7-mime signed data objects, multipartsigned messages require that all signatures use the same message digest algorithm. The generateContentType method returns the following string: multipartsigned; protocol=applicationpkcs7-signature

6.3.3.4 Creating Digital Envelopes

An SMIME digital envelope encrypted message is represented by the SmimeEnveloped class. This is a MIME entity which is formed by encrypting a MIME body part with some symmetric encryption algorithm eg, Triple-Des or RC2 and a randomly generated session key, then encrypting the session key with the RSA public key for each intended message recipient. In the following example, doc is an instance of MimeBodyPart, which is to be wrapped in an instance of SmimeEnveloped, and recipientCert is the recipients certificate. SmimeEnveloped env = new SmimeEnvelopeddoc, Smime.dES_EDE3_CBC; env.addRecipient recipientCert; Any number of envelope recipients may be added by making repeated calls to addRecipient.

6.3.3.5 Creating Certificates-Only Messages