IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.smime.ecc
Class SMimeEccSuiteBDemo

java.lang.Object
  extended by demo.smime.ecc.SMimeEccSuiteBDemo

public class SMimeEccSuiteBDemo
extends java.lang.Object

This class demonstrates the usage of the IAIK S/MIME implementation to create and parse ECDSA signed and/or ECDH based encrypted S/MIMEv3 messages according to RFC 5008 "Suite B in Secure/Multipurpose Internet Mail Extensions (S/MIME)".
The following algorithms are required by Suite B of the United States Security Agency (NSA) for use of ECC in S/MIME (see RFC 5008):

                          Security Level 1   Security Level 2
                          ----------------   ----------------
    Message Digest:       SHA-256            SHA-384
    Signature:            ECDSA with P-256   ECDSA with P-384
    
    

                           Security Level 1   Security Level 2
                          ----------------   ----------------
    Key Agreement:        ECDH with P-256    ECDH with P-384
    Key Derivation:       SHA-256            SHA-384
    Key Wrap:             AES-128 Key Wrap   AES-256 Key Wrap
    Content Encryption:   AES-128 CBC        AES-256 CBC
 

The key encryption algorithms used during ECDH are dhSinglePass-stdDH-sha256kdf-scheme for Security Level 1 and dhSinglePass-stdDH-sha384kdf-scheme for Security Level 2.

Any keys/certificates required for this demo are read from a keystore file "cmsecc.keystore" located in your current working directory. If the keystore file does not exist you can create it by running the SetupCMSEccKeyStore program.

Additionally to iaik_cms.jar you also must have iaik_jce_(full).jar (IAIK-JCE, https://sic.tech/products/core-crypto-toolkits/jca-jce/), and iaik_eccelarate.jar (IAIK-ECCelerateTM, https://sic.tech/products/core-crypto-toolkits/eccelerate/) in your classpath.

To run this demo the following packages are required:

See Also:
SetupCMSEccKeyStore, SignedContent, EncryptedContent

Constructor Summary
SMimeEccSuiteBDemo()
          Default constructor.
 
Method Summary
 javax.mail.Message createEncryptedMessage(javax.mail.Session session, iaik.asn1.structures.AlgorithmID contentEA, int keyLength, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int kekLength, iaik.x509.X509Certificate recipientCertificate, iaik.x509.X509Certificate encryptionCertOfSender)
          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 createSignedAndEncryptedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, boolean implicit, iaik.asn1.structures.AlgorithmID hashAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerPrivateKey, iaik.x509.X509Certificate[] signerCertificates, iaik.x509.X509Certificate encryptionCertOfSigner, iaik.asn1.structures.AlgorithmID contentEA, int keyLength, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlgorithm, int kekLength, iaik.x509.X509Certificate recipientCertificate)
          Creates a signed and encrypted message.
 javax.mail.Message createSignedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, boolean implicit, iaik.asn1.structures.AlgorithmID hashAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerPrivateKey, iaik.x509.X509Certificate[] signerCertificates, iaik.x509.X509Certificate encryptionCertOfSigner)
          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

SMimeEccSuiteBDemo

public SMimeEccSuiteBDemo()
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

createSignedMessage

public javax.mail.Message createSignedMessage(javax.mail.Session session,
                                              javax.activation.DataHandler dataHandler,
                                              boolean implicit,
                                              iaik.asn1.structures.AlgorithmID hashAlgorithm,
                                              iaik.asn1.structures.AlgorithmID signatureAlgorithm,
                                              java.security.PrivateKey signerPrivateKey,
                                              iaik.x509.X509Certificate[] signerCertificates,
                                              iaik.x509.X509Certificate encryptionCertOfSigner)
                                       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
hashAlgorithm - the hash algorithm to be used
signatureAlgorithm - the signature algorithm to be used
signerPrivateKey - the private key of the signer
signerCertificates - the certificate chain of the signer
encryptionCertOfSigner - the encryption certificate of the signer (to be announced within the SignerInfo)
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,
                                                 iaik.asn1.structures.AlgorithmID keyEA,
                                                 iaik.asn1.structures.AlgorithmID keyWrapAlg,
                                                 int kekLength,
                                                 iaik.x509.X509Certificate recipientCertificate,
                                                 iaik.x509.X509Certificate encryptionCertOfSender)
                                          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
keyEA - the key encryption algorithm to be used
keyWrapAlg - the key wrap algorithm to be used
kekLength - the length of the key encryption algorithm
recipientCertificate - the encryption certificate of the recipient
encryptionCertOfSender - the encryption certificate of the sender
Returns:
the encrypted message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createSignedAndEncryptedMessage

public javax.mail.Message createSignedAndEncryptedMessage(javax.mail.Session session,
                                                          javax.activation.DataHandler dataHandler,
                                                          boolean implicit,
                                                          iaik.asn1.structures.AlgorithmID hashAlgorithm,
                                                          iaik.asn1.structures.AlgorithmID signatureAlgorithm,
                                                          java.security.PrivateKey signerPrivateKey,
                                                          iaik.x509.X509Certificate[] signerCertificates,
                                                          iaik.x509.X509Certificate encryptionCertOfSigner,
                                                          iaik.asn1.structures.AlgorithmID contentEA,
                                                          int keyLength,
                                                          iaik.asn1.structures.AlgorithmID keyEA,
                                                          iaik.asn1.structures.AlgorithmID keyWrapAlgorithm,
                                                          int kekLength,
                                                          iaik.x509.X509Certificate recipientCertificate)
                                                   throws javax.mail.MessagingException
Creates a signed and encrypted message.

Parameters:
session - the mail session
dataHandler - the content of the message to be signed and encrypted
implicit - whether to use implicit (application/pkcs7-mime) or explicit (multipart/signed) signing
hashAlgorithm - the hash algorithm to be used
signatureAlgorithm - the signature algorithm to be used
signerPrivateKey - the private key of the signer
signerCertificates - the certificate chain of the signer
encryptionCertOfSigner - the encryption certificate of the signer (to be announced within the SignerInfo)
contentEA - the content encryption algorithm to be used
keyLength - the length of the secret content encryption key to be created and used
keyEA - the key encryption algorithm to be used
keyWrapAlgorithm - the key wrap algorithm to be used
kekLength - the length of the key encryption algorithm
recipientCertificate - the encryption certificate of the recipient
Returns:
the signed and 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.lang.Exception
The main method.

Throws:
java.lang.Exception

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

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