public class SMimeV4EccDemo extends java.lang.Object
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).
| Constructor and Description |
|---|
SMimeV4EccDemo()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
jakarta.mail.Message |
createEncryptedMessage(jakarta.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.
|
jakarta.mail.Message |
createMessage(jakarta.mail.Session session,
java.lang.String subject)
Creates a MIME message container with the given subject for the given session.
|
jakarta.mail.Message |
createSignedAndEncryptedMessage(jakarta.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,
jakarta.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.
|
jakarta.mail.Message |
createSignedMessage(jakarta.mail.Session session,
jakarta.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(jakarta.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(jakarta.mail.Session session,
jakarta.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(jakarta.mail.Session session,
jakarta.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.
|
public SMimeV4EccDemo()
public void start() throws java.lang.Exception
java.lang.Exception - if an error occurspublic void startSigningDemo(jakarta.mail.Session session, jakarta.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 signerjava.lang.Exception - if an error occurspublic void startEncryptionDemo(jakarta.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 recipientsjava.lang.Exception - if an error occurspublic void startSigningAndEncryptionDemo(jakarta.mail.Session session, jakarta.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 recipientsjava.lang.Exception - if an error occurspublic jakarta.mail.Message createMessage(jakarta.mail.Session session, java.lang.String subject) throws jakarta.mail.MessagingException
session - the mail sesionsubject - the subject of the messagejakarta.mail.MessagingException - if the message cannot be createdpublic jakarta.mail.Message createSignedMessage(jakarta.mail.Session session, jakarta.activation.DataHandler dataHandler, boolean implicit, iaik.asn1.structures.AlgorithmID digestAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] signerCertificates) throws jakarta.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 signerjakarta.mail.MessagingException - if an error occurs when creating the messagepublic jakarta.mail.Message createEncryptedMessage(jakarta.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 jakarta.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 recipientsjakarta.mail.MessagingException - if an error occurs when creating the messagepublic jakarta.mail.Message createSignedAndEncryptedMessage(jakarta.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, jakarta.activation.DataHandler dataHandler, boolean implicit, boolean authEncrypt, java.security.PrivateKey signerKey, iaik.x509.X509Certificate[] signerCerts, iaik.x509.X509Certificate[] recipientCerts) throws jakarta.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 recipientsjakarta.mail.MessagingException - if an error occurs when creating the messagepublic static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception