|
IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdemo.smime.ecc.SMimeV4EccDemo
public class SMimeV4EccDemo
This class demonstrates the usage of the IAIK S/MIME implementation. It shows how to create signed and/or (authenticated) encrypted S/MIMEv4 messages using ECC keys and how to parse them and verify the signatures and decrypt the content, respectively.
This demo uses several combinations of cryptographic algorithms that may not used in this
way in practice. For a simple demos using only one set of algorithms see the SimpleSMimeV4EcDemo
and SimpleSMimeV4EdDemo
.
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:
iaik_cms.jar
iaik_jce(_full).jar
(IAIK-JCE Core Crypto Library).
iaik_eccelerate.jar
(IAIK ECC Library).
mail.jar
(JavaMail API).
activation.jar
(Java Activation Framework; required for JDK versions < 1.6).
Constructor Summary | |
---|---|
SMimeV4EccDemo()
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 keyWrapAlgorithm,
int kekLength,
boolean authEncrypt,
iaik.x509.X509Certificate[] recipientCerts)
Creates an (maybe authenticated) 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,
iaik.asn1.structures.AlgorithmID digestAlgorithm,
iaik.asn1.structures.AlgorithmID signatureAlgorithm,
iaik.asn1.structures.AlgorithmID contentEA,
int keyLength,
iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlgorithm,
int kekLength,
javax.activation.DataHandler dataHandler,
boolean implicit,
boolean authEncrypt,
java.security.PrivateKey signerKey,
iaik.x509.X509Certificate[] signerCerts,
iaik.x509.X509Certificate[] recipientCerts)
Creates a signed and (maybe authenticated) 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,
java.security.PrivateKey signerKey,
iaik.x509.X509Certificate[] signerCertificates)
Creates a signed message. |
static void |
main(java.lang.String[] argv)
The main method. |
void |
start()
Starts the demo. |
void |
startEncryptionDemo(javax.mail.Session session,
iaik.asn1.structures.AlgorithmID contentEA,
int keyLength,
iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlgorithm,
int kekLength,
boolean authEncrypt,
iaik.x509.X509Certificate[] recipientCerts)
Starts the (maybe authenticated) encryption demo. |
void |
startSigningAndEncryptionDemo(javax.mail.Session session,
javax.activation.DataHandler multipart,
iaik.asn1.structures.AlgorithmID digestAlgorithm,
iaik.asn1.structures.AlgorithmID signatureAlgorithm,
iaik.asn1.structures.AlgorithmID contentEA,
int keyLength,
iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlgorithm,
int kekLength,
boolean authEncrypt,
java.security.PrivateKey signerKey,
iaik.x509.X509Certificate[] signerCerts,
iaik.x509.X509Certificate[] recipientCerts)
Starts the signing + (maybe authenticated) encryption demo. |
void |
startSigningDemo(javax.mail.Session session,
javax.activation.DataHandler multipart,
iaik.asn1.structures.AlgorithmID digestAlgorithm,
iaik.asn1.structures.AlgorithmID signatureAlgorithm,
java.security.PrivateKey signerKey,
iaik.x509.X509Certificate[] signerCerts)
Starts the signing demo. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SMimeV4EccDemo()
Method Detail |
---|
public void start() throws java.lang.Exception
java.lang.Exception
- if an error occurspublic void startSigningDemo(javax.mail.Session session, javax.activation.DataHandler multipart, iaik.asn1.structures.AlgorithmID digestAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] signerCerts) throws java.lang.Exception
session
- the mail sessionmultipart
- the multipart content of the message to be signeddigestAlgorithm
- the digest algorithm to be usedsignatureAlgorithm
- the signature algorithm to be usedsignerKey
- the private key of the signersignerCerts
- the certificate chain of the signer
java.lang.Exception
- if an error occurspublic void startEncryptionDemo(javax.mail.Session session, iaik.asn1.structures.AlgorithmID contentEA, int keyLength, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlgorithm, int kekLength, boolean authEncrypt, iaik.x509.X509Certificate[] recipientCerts) throws java.lang.Exception
session
- the mail sessioncontentEA
- the content encryption algorithm to be usedkeyLength
- the length of the secret content encryption key to be created and usedkeyEA
- the (key agreement) algorithm to use for creating a shared secret
key encryption key for encrypting the symmetric key
(e.g. AlgorithmID.esdhKeyAgreement)keyWrapAlgorithm
- the key wrap algorithm to be used for encrypting (wrapping)
the content-encryption key with the shared key-encryption
created according to the requested key agreement protocolkekLength
- the length of the shared key encryption key to be generatedauthEncrypt
- whether to create an authenticated encrypted messagerecipientCerts
- the certificates of the recipients
java.lang.Exception
- if an error occurspublic void startSigningAndEncryptionDemo(javax.mail.Session session, javax.activation.DataHandler multipart, iaik.asn1.structures.AlgorithmID digestAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, iaik.asn1.structures.AlgorithmID contentEA, int keyLength, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlgorithm, int kekLength, boolean authEncrypt, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] signerCerts, iaik.x509.X509Certificate[] recipientCerts) throws java.lang.Exception
session
- the mail sessionmultipart
- the Multipart content to be signed and encrypteddigestAlgorithm
- the digest algorithm to be used for signingsignatureAlgorithm
- the signature algorithm to be usedcontentEA
- the content encryption algorithm to be usedkeyLength
- the length of the secret content encryption key to be created and usedkeyEA
- the (key agreement) algorithm to use for creating a shared secret
key encryption key for encrypting the symmetric key
(e.g. AlgorithmID.esdhKeyAgreement)keyWrapAlgorithm
- the key wrap algorithm to be used for encrypting (wrapping)
the content-encryption key with the shared key-encryption
created according to the requested key agreement protocolkekLength
- the length of the shared key encryption key to be generatedauthEncrypt
- whether to create an authenticated encrypted messagesignerKey
- the private key of the signersignerCerts
- the certificate chain of the signerrecipientCerts
- the certificates of the recipients
java.lang.Exception
- if an error occurspublic javax.mail.Message createMessage(javax.mail.Session session, java.lang.String subject) throws javax.mail.MessagingException
session
- the mail sesionsubject
- the subject of the message
javax.mail.MessagingException
- if the message cannot be createdpublic javax.mail.Message createSignedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, boolean implicit, iaik.asn1.structures.AlgorithmID digestAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] signerCertificates) throws javax.mail.MessagingException
session
- the mail sessiondataHandler
- the content of the message to be signedimplicit
- whether to use implicit (application/pkcs7-mime) or explicit
(multipart/signed) signingdigestAlgorithm
- the digest algorithm to be usedsignatureAlgorithm
- the signature algorithm to be usedsignerKey
- the private key of the signersignerCertificates
- the certificate chain of the signer
javax.mail.MessagingException
- if an error occurs when creating the messagepublic javax.mail.Message createEncryptedMessage(javax.mail.Session session, iaik.asn1.structures.AlgorithmID contentEA, int keyLength, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlgorithm, int kekLength, boolean authEncrypt, iaik.x509.X509Certificate[] recipientCerts) throws javax.mail.MessagingException
session
- the mail sessioncontentEA
- the content encryption algorithm to be usedkeyLength
- the length of the secret content encryption key to be created and usedkeyEA
- the (key agreement) algorithm to use for creating a shared secret
key encryption key for encrypting the symmetric key
(e.g. AlgorithmID.esdhKeyAgreement)keyWrapAlgorithm
- the key wrap algorithm to be used for encrypting (wrapping)
the content-encryption key with the shared key-encryption
created according to the requested key agreement protocolkekLength
- the length of the shared key encryption key to be generatedauthEncrypt
- whether to create an authenticated encrypted messagerecipientCerts
- the certificates of the recipients
javax.mail.MessagingException
- if an error occurs when creating the messagepublic javax.mail.Message createSignedAndEncryptedMessage(javax.mail.Session session, iaik.asn1.structures.AlgorithmID digestAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, iaik.asn1.structures.AlgorithmID contentEA, int keyLength, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlgorithm, int kekLength, javax.activation.DataHandler dataHandler, boolean implicit, boolean authEncrypt, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] signerCerts, iaik.x509.X509Certificate[] recipientCerts) throws javax.mail.MessagingException
session
- the mail sessiondigestAlgorithm
- the digest algorithm to be used for signingsignatureAlgorithm
- the signature algorithm to be usedcontentEA
- the content encryption algorithm to be usedkeyLength
- the length of the secret content encryption key to be created and usedkeyEA
- the (key agreement) algorithm to use for creating a shared secret
key encryption key for encrypting the symmetric key
(e.g. AlgorithmID.esdhKeyAgreement)keyWrapAlgorithm
- the key wrap algorithm to be used for encrypting (wrapping)
the content-encryption key with the shared key-encryption
created according to the requested key agreement protocolkekLength
- the length of the shared key encryption key to be generateddataHandler
- the content of the message to be signed and encryptedimplicit
- whether to use implicit (application/pkcs7-mime) or explicit
(multipart/signed) signingauthEncrypt
- whether to create an authenticated encrypted messagesignerKey
- the private key of the signersignerCerts
- the certificate chain of the signerrecipientCerts
- the certificates of the recipients
javax.mail.MessagingException
- if an error occurs when creating the messagepublic static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
|
IAIK CMS/SMIME Toolkit Demo 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 |
![]() |