public class SMimeEccSuiteBDemo extends java.lang.Object
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
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:
iaik_cms.jar
iaik_jce(_full).jar
(IAIK-JCE Core Crypto Library).
iaik_eccelerate.jar
(IAIK ECC Library).
SetupCMSEccKeyStore
,
SignedContent
,
EncryptedContent
Constructor and Description |
---|
SMimeEccSuiteBDemo()
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 keyWrapAlg,
int kekLength,
iaik.x509.X509Certificate recipientCertificate,
iaik.x509.X509Certificate encryptionCertOfSender)
Creates an 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,
jakarta.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.
|
jakarta.mail.Message |
createSignedMessage(jakarta.mail.Session session,
jakarta.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.
|
public SMimeEccSuiteBDemo()
public void start() throws java.io.IOException
java.io.IOException
- if an I/O related 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 hashAlgorithm, iaik.asn1.structures.AlgorithmID signatureAlgorithm, java.security.PrivateKey signerPrivateKey, iaik.x509.X509Certificate[] signerCertificates, iaik.x509.X509Certificate encryptionCertOfSigner) 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) signinghashAlgorithm
- the hash algorithm to be usedsignatureAlgorithm
- the signature algorithm to be usedsignerPrivateKey
- the private key of the signersignerCertificates
- the certificate chain of the signerencryptionCertOfSigner
- the encryption certificate of the signer
(to be announced within the SignerInfo)jakarta.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 keyWrapAlg, int kekLength, iaik.x509.X509Certificate recipientCertificate, iaik.x509.X509Certificate encryptionCertOfSender) 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 encryption algorithm to be usedkeyWrapAlg
- the key wrap algorithm to be usedkekLength
- the length of the key encryption algorithmrecipientCertificate
- the encryption certificate of the recipientencryptionCertOfSender
- the encryption certificate of the senderjakarta.mail.MessagingException
- if an error occurs when creating the messagepublic jakarta.mail.Message createSignedAndEncryptedMessage(jakarta.mail.Session session, jakarta.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 jakarta.mail.MessagingException
session
- the mail sessiondataHandler
- the content of the message to be signed and encryptedimplicit
- whether to use implicit (application/pkcs7-mime) or explicit
(multipart/signed) signinghashAlgorithm
- the hash algorithm to be usedsignatureAlgorithm
- the signature algorithm to be usedsignerPrivateKey
- the private key of the signersignerCertificates
- the certificate chain of the signerencryptionCertOfSigner
- the encryption certificate of the signer
(to be announced within the SignerInfo)contentEA
- the content encryption algorithm to be usedkeyLength
- the length of the secret content encryption key to be created and usedkeyEA
- the key encryption algorithm to be usedkeyWrapAlgorithm
- the key wrap algorithm to be usedkekLength
- the length of the key encryption algorithmrecipientCertificate
- the encryption certificate of the recipientjakarta.mail.MessagingException
- if an error occurs when creating the messagepublic static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception