IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.smime.basic
Class SMimeEnvelopedDemoAEAD

java.lang.Object
  extended by demo.smime.basic.SMimeEnvelopedDemoAEAD

public class SMimeEnvelopedDemoAEAD
extends java.lang.Object

This class demonstrates the usage of the IAIK S/MIME implementation. It shows how to create signed and/or encrypted S/MIME messages and how to parse them and verify the signatures and decrypt the content, respectively. This demos creates encrypted messages using an AEAD cipher mode (like GCM). Although CMS and S/MIME generally use AEAD cipher modes with the AuthEnvelopedData content type, it is technically possible to also use AEAD cipher modes with the EnvelopedData content type (when appending the mac value to the cipher text). This demo shows how to encrypt S/MIME messages with AEAD cipher modes when using the CMS EnvelopedData type.

To run this demo the following packages are required:

This demo requires Java 7 or later.


Constructor Summary
SMimeEnvelopedDemoAEAD()
          Default constructor.
 
Method Summary
 javax.mail.Message createEncryptedMessage(javax.mail.Session session, iaik.asn1.structures.AlgorithmID contentEA, int keyLength)
          Creates an encrypted message.
 javax.mail.Message createMessage(javax.mail.Session session, java.lang.String subject)
          Creates a MIME message container with the given subject for the given session.
 javax.mail.Message createPlainMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler)
          Creates a simple plain (neither signed nor encrypted) message.
 javax.mail.Message createSignedAndEncryptedMessage(javax.mail.Session session, iaik.asn1.structures.AlgorithmID contentEA, int keyLength, javax.activation.DataHandler dataHandler, boolean implicit, boolean authEncrypt)
          Creates a signed and encrypted message.
 javax.mail.Message createSignedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, boolean implicit, iaik.asn1.structures.AlgorithmID digestAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm)
          Creates a signed message.
static void main(java.lang.String[] argv)
          The main method.
 void start()
          Starts the demo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMimeEnvelopedDemoAEAD

public SMimeEnvelopedDemoAEAD()
Default constructor. Reads certificates and keys from the demo keystore.

Method Detail

start

public void start()
           throws java.io.IOException
Starts the demo.

Throws:
java.io.IOException - if an I/O related error occurs

createMessage

public javax.mail.Message createMessage(javax.mail.Session session,
                                        java.lang.String subject)
                                 throws javax.mail.MessagingException
Creates a MIME message container with the given subject for the given session.

Parameters:
session - the mail sesion
subject - the subject of the message
Returns:
the MIME message with FROM, TO, DATE and SUBJECT headers (without content)
Throws:
javax.mail.MessagingException - if the message cannot be created

createPlainMessage

public javax.mail.Message createPlainMessage(javax.mail.Session session,
                                             javax.activation.DataHandler dataHandler)
                                      throws javax.mail.MessagingException
Creates a simple plain (neither signed nor encrypted) message.

Parameters:
session - the mail session
dataHandler - the content of the message
Returns:
the plain message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createSignedAndEncryptedMessage

public javax.mail.Message createSignedAndEncryptedMessage(javax.mail.Session session,
                                                          iaik.asn1.structures.AlgorithmID contentEA,
                                                          int keyLength,
                                                          javax.activation.DataHandler dataHandler,
                                                          boolean implicit,
                                                          boolean authEncrypt)
                                                   throws javax.mail.MessagingException
Creates a signed and encrypted message.

Parameters:
session - the mail session
contentEA - the content encryption algorithm to be used
keyLength - the length of the secret content encryption key to be created and used
dataHandler - the content of the message to be signed and encrypted
implicit - whether to use implicit (application/pkcs7-mime) or explicit (multipart/signed) signing
authEncrypt - whether to create an encrypted message
Returns:
the signed and encrypted message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createSignedMessage

public javax.mail.Message createSignedMessage(javax.mail.Session session,
                                              javax.activation.DataHandler dataHandler,
                                              boolean implicit,
                                              iaik.asn1.structures.AlgorithmID digestAlgorithm,
                                              iaik.asn1.structures.AlgorithmID signatureAlgorithm)
                                       throws javax.mail.MessagingException
Creates a signed message.

Parameters:
session - the mail session
dataHandler - the content of the message to be signed
implicit - whether to use implicit (application/pkcs7-mime) or explicit (multipart/signed) signing
digestAlgorithm - the digest algorithm to be used
signatureAlgorithm - the signature algorithm to be used
Returns:
the signed message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createEncryptedMessage

public javax.mail.Message createEncryptedMessage(javax.mail.Session session,
                                                 iaik.asn1.structures.AlgorithmID contentEA,
                                                 int keyLength)
                                          throws javax.mail.MessagingException
Creates an encrypted message.

Parameters:
session - the mail session
contentEA - the content encryption algorithm to be used
keyLength - the length of the secret content encryption key to be created and used
Returns:
the encrypted message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

main

public static void main(java.lang.String[] argv)
                 throws java.io.IOException
The main method.

Throws:
java.io.IOException

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

v6.1
(c) 2002 IAIK, (c) 2003 - 2025 SIC