|
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.cms.ecc.EdDHEnvelopedDataDemo
public class EdDHEnvelopedDataDemo
Demonstrates the usage of class EnvelopedDataStream
,
EnvelopedData
and EnvelopedDataOutputStream
for encrypting data using the CMS type EnvelopedData by using the
Ephemeral-Static ECDH Elliptic Curve Diffie-Hellman (ECDH) key agreement
algorithm with curve25519 and curve448 in the Cryptographic Message Syntax (CMS)
according to RFC 8418.
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.
EnvelopedDataStream
,
EnvelopedData
,
RecipientInfo
,
KeyAgreeRecipientInfo
,
SetupCMSEccKeyStore
Constructor Summary | |
---|---|
EdDHEnvelopedDataDemo()
Setup the demo certificate chains. |
Method Summary | |
---|---|
byte[] |
createEnvelopedData(byte[] message,
iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlg,
int kekLength)
Creates a CMS EnvelopedData message. |
byte[] |
createEnvelopedDataOutputStream(byte[] message,
iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlg,
int kekLength)
Creates a CMS EnvelopedData message using the
EnvelopedDataOutputStream
class. |
byte[] |
createEnvelopedDataStream(byte[] message,
iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlg,
int kekLength)
Creates a CMS EnvelopedDataStream message. |
iaik.cms.RecipientInfo[] |
createRecipients(iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlg,
int kekLength)
Creates the RecipientInfos. |
byte[] |
getEnvelopedData(byte[] enc,
java.security.Key key,
int recipientInfoIndex)
Decrypts the encrypted content of the given EnvelopedData object for
the recipient identified by its index into the recipientInfos field. |
byte[] |
getEnvelopedData(byte[] enc,
java.security.Key key,
iaik.cms.KeyIdentifier recipientID)
Decrypts the encrypted content of the given EnvelopedData object for
the recipient identified by recipient identifier. |
byte[] |
getEnvelopedData(byte[] enc,
java.security.Key key,
iaik.x509.X509Certificate recipientCert)
Decrypts the encrypted content of the given EnvelopedData object for
the recipient identified by its recipient certificate. |
byte[] |
getEnvelopedDataStream(byte[] encoding,
java.security.Key key,
int recipientInfoIndex)
Decrypts the encrypted content of the given EnvelopedData object for
the recipient identified by its index into the recipientInfos field. |
byte[] |
getEnvelopedDataStream(byte[] encoding,
java.security.Key key,
iaik.cms.KeyIdentifier recipientID)
Decrypts the encrypted content of the given EnvelopedData object for
the recipient identified by recipient identifier. |
static void |
main(java.lang.String[] argv)
Main method. |
void |
parseEnvelopedDataWithRecipientIdentifier(boolean stream,
byte[] encodedEnvelopedData)
Parses an EnvelopedData and decrypts the content for all test recipients using their recipient identifiers for identifying the recipient. |
void |
parseEnvelopedDataWithRecipientInfoIndex(boolean stream,
byte[] encodedEnvelopedData)
Parses an EnvelopedData and decrypts the content for all test recipients using the index into the recipientInfos field for identifying the recipient. |
void |
start()
Runs the demo. |
void |
start(iaik.asn1.structures.AlgorithmID keyEA,
iaik.asn1.structures.AlgorithmID keyWrapAlg,
int kekLength)
Runs the demo for the given key encryption (key agreement) algorithm, and key wrap algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EdDHEnvelopedDataDemo() throws java.io.IOException
SetupCMSEccKeyStore
program.
java.io.IOException
- if keys/certificates cannot be read from the keystoreMethod Detail |
---|
public byte[] createEnvelopedDataStream(byte[] message, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int kekLength) throws iaik.cms.CMSException, java.io.IOException
EnvelopedDataStream
message.
message
- the message to be enveloped, as byte representationkeyEA
- the key encryption (key agreement) algorithm used for creating
a shared key encryption key for encrypting the secret content
encryption key with itkeyWrapAlg
- the key wrap algorithm to be used for wrapping (encrypting)
the content encryption keykekLength
- the length of the key encryption key to be created for
encrypting the content encryption key with it
EnvelopedData
object just created
iaik.cms.CMSException
- if the EnvelopedData
object cannot
be created
java.io.IOException
- if an I/O error occurspublic byte[] createEnvelopedDataOutputStream(byte[] message, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int kekLength) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
message using the
EnvelopedDataOutputStream
class.
message
- the message to be enveloped, as byte representationkeyEA
- the key encryption (key agreement) algorithm used for creating
a shared key encryption key for encrypting the secret content
encryption key with itkeyWrapAlg
- the key wrap algorithm to be used for wrapping (encrypting)
the content encryption keykekLength
- the length of the key encryption key to be created for
encrypting the content encryption key with it
EnvelopedData
object just created
iaik.cms.CMSException
- if the EnvelopedData
object cannot
be created
java.io.IOException
- if an I/O error occurspublic byte[] getEnvelopedDataStream(byte[] encoding, java.security.Key key, int recipientInfoIndex) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
object for
the recipient identified by its index into the recipientInfos field.
encoding
- the EnvelopedData
object as DER encoded byte arraykey
- the key to decrypt the messagerecipientInfoIndex
- the index into the RecipientInfo
array
to which the specified key belongs
iaik.cms.CMSException
- if the message cannot be recovered
java.io.IOException
- if a stream read/write error occurspublic byte[] getEnvelopedDataStream(byte[] encoding, java.security.Key key, iaik.cms.KeyIdentifier recipientID) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
object for
the recipient identified by recipient identifier.
encoding
- the EnvelopedData
object as DER encoded byte arraykey
- the key to decrypt the messagerecipientID
- the recipient identifier uniquely identifying the key of the
recipient
iaik.cms.CMSException
- if the message cannot be recovered
java.io.IOException
- if a stream read/write error occurspublic byte[] createEnvelopedData(byte[] message, iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int kekLength) throws iaik.cms.CMSException
EnvelopedData
message.
message
- the message to be enveloped, as byte representationkeyEA
- the key encryption (key agreement) algorithm used for creating
a shared key encryption key for encrypting the secret content
encryption key with itkeyWrapAlg
- the key wrap algorithm to be used for wrapping (encrypting)
the content encryption keykekLength
- the length of the key encryption key to be created for
encrypting the content encryption key with it
EnvelopedData
, as byte array
iaik.cms.CMSException
- if the EnvelopedData
object cannot
be createdpublic byte[] getEnvelopedData(byte[] enc, java.security.Key key, int recipientInfoIndex) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
object for
the recipient identified by its index into the recipientInfos field.
enc
- the encoded EnvelopedData
key
- the key to decrypt the messagerecipientInfoIndex
- the index into the RecipientInfo
array
to which the specified key belongs
iaik.cms.CMSException
- if the message cannot be recovered
java.io.IOException
- if an I/O error occurspublic byte[] getEnvelopedData(byte[] enc, java.security.Key key, iaik.cms.KeyIdentifier recipientID) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
object for
the recipient identified by recipient identifier.
This way of decrypting the content may be used for any type of RecipientInfo (KeyTransRecipientInfo, KeyAgreeRecipientInfo, KEKRecipientInfo). The recipient in mind is identified by its recipient identifier.
enc
- the encoded AuthenticatedData
key
- the key to decrypt the messagerecipientID
- the recipient identifier uniquely identifying the key of the
recipient
iaik.cms.CMSException
- if the message cannot be recovered
java.io.IOException
- if an I/O error occurspublic byte[] getEnvelopedData(byte[] enc, java.security.Key key, iaik.x509.X509Certificate recipientCert) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
object for
the recipient identified by its recipient certificate.
enc
- the encoded EnvelopedData
key
- the key to decrypt the messagerecipientCert
- the certificate of the recipient
iaik.cms.CMSException
- if the message cannot be recovered
java.io.IOException
public iaik.cms.RecipientInfo[] createRecipients(iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int kekLength) throws iaik.cms.CMSException
keyEA
- the key encryption (key agreement) algorithm used for creating
a shared key encryption key for encrypting the secret content
encryption key with itkeyWrapAlg
- the key wrap algorithm to be used for wrapping (encrypting)
the content encryption keykekLength
- the length of the key encryption key to be created for
encrypting the content encryption key with it
iaik.cms.CMSException
- if an error occurs when creating the recipient infospublic void parseEnvelopedDataWithRecipientInfoIndex(boolean stream, byte[] encodedEnvelopedData) throws java.lang.Exception
stream
- whether to use EnvelopedDataStream or EnvelopedDataencodedEnvelopedData
- the encoded EnvelopedData object
java.lang.Exception
- if some error occurs during decoding/decryptionpublic void parseEnvelopedDataWithRecipientIdentifier(boolean stream, byte[] encodedEnvelopedData) throws java.lang.Exception
stream
- whether to use EnvelopedDataStream or EnvelopedDataencodedEnvelopedData
- the encoded EnvelopedData object
java.lang.Exception
- if some error occurs during decoding/decryptionpublic void start()
public void start(iaik.asn1.structures.AlgorithmID keyEA, iaik.asn1.structures.AlgorithmID keyWrapAlg, int kekLength)
keyEA
- the key encryption (key agreement) algorithm used for creating
a shared key encryption key for encrypting the secret content
encryption key with itkeyWrapAlg
- the key wrap algorithm to be used for wrapping (encrypting)
the content encryption keykekLength
- the length of the key encryption key to be created for
encrypting the content encryption key with itpublic static void main(java.lang.String[] argv) throws java.lang.Exception
java.io.IOException
- if an I/O error occurs when reading required keys
and certificates from the keystore file
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 |
![]() |