|
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.envelopedData.RC2EnvelopedDataDemo
public class RC2EnvelopedDataDemo
This class demonstrates the EnvelopedDataStream/EncryptedContentInfoStream usages for the RC2 algorithm.
This demo compares the usage of class EnvelopedDataStream for encrypting the content using RC2 with automatic (transparent) key/parameter handling against explicit key/parameter/EncrypedContentInfoStream handling.
All keys and certificates are read from a keystore created by the SetupCMSKeyStore program.
RC2 parameters are defined as:
RC2-CBC parameter ::= SEQUENCE {
rc2ParameterVersion INTEGER,
iv OCTET STRING (8)}
For the effective-key-bits of 40, 64, and 128, the
rc2ParameterVersion values are 160, 120, 58 respectively.
| Constructor Summary | |
|---|---|
RC2EnvelopedDataDemo()
Setup the demo certificate chains. |
|
| Method Summary | |
|---|---|
byte[] |
createEncryptedContentInfoStream(byte[] message,
iaik.asn1.structures.AlgorithmID contentEA,
int keyLength)
Creates a CMS EnvelopedDataStream message. |
byte[] |
createEnvelopedDataStream(byte[] message,
iaik.asn1.structures.AlgorithmID contentEA,
int keyLength)
Creates a CMS EnvelopedDataStream message. |
byte[] |
getEncryptedContentInfoStream(byte[] encoding,
java.security.PrivateKey privateKey,
int recipientInfoIndex)
Decrypts the encrypted content of the given EnvelopedData object for the
specified recipient and returns the decrypted (= original) message. |
byte[] |
getEnvelopedDataStream(byte[] encoding,
java.security.PrivateKey privateKey,
int recipientInfoIndex)
Decrypts the encrypted content of the given EnvelopedData object for the
specified recipient and returns the decrypted (= original) message. |
static void |
main(java.lang.String[] argv)
The main method. |
void |
start()
Starts the test. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RC2EnvelopedDataDemo()
throws java.io.IOException
java.io.IOException - if an file read error occurs| Method Detail |
|---|
public byte[] createEnvelopedDataStream(byte[] message,
iaik.asn1.structures.AlgorithmID contentEA,
int keyLength)
throws java.lang.Exception
EnvelopedDataStream message.
message - the message to be enveloped, as byte representationcontentEA - the content encryption algorithmkeyLength - the key length for the symmetric key
EnvelopedData object just created
iaik.cms.CMSException - if the EnvelopedData object cannot
be created
java.lang.Exception
public byte[] createEncryptedContentInfoStream(byte[] message,
iaik.asn1.structures.AlgorithmID contentEA,
int keyLength)
throws java.lang.Exception
EnvelopedDataStream message.
Keys and parameters, and EncryptedContentInfoStream are created outside the EnvelopedDataStream class.
message - the message to be enveloped, as byte representationcontentEA - the content encryption algorithmkeyLength - the key length for the symmetric key
EnvelopedData object just created
java.lang.Exception - if the EnvelopedData object cannot
be created
public byte[] getEncryptedContentInfoStream(byte[] encoding,
java.security.PrivateKey privateKey,
int recipientInfoIndex)
throws java.lang.Exception
EnvelopedData object for the
specified recipient and returns the decrypted (= original) message.
Decryption and cipher setup and EncryptedContentInfoStrean processing is performed outside class EnvelopedDataStream.
encoding - the EnvelopedData object as DER encoded byte arrayprivateKey - the private key to decrypt the messagerecipientInfoIndex - the index into the RecipientInfo array
to which the specified private key belongs
java.lang.Exception - if the message cannot be recovered
public byte[] getEnvelopedDataStream(byte[] encoding,
java.security.PrivateKey privateKey,
int recipientInfoIndex)
throws java.lang.Exception
EnvelopedData object for the
specified recipient and returns the decrypted (= original) message.
encoding - the EnvelopedData object as DER encoded byte arrayprivateKey - the private key to decrypt the messagerecipientInfoIndex - the index into the RecipientInfo array
to which the specified private key belongs
java.lang.Exception - if the message cannot be recoveredpublic void start()
public static void main(java.lang.String[] argv)
throws java.lang.Exception
java.lang.Exception - if some error occurs
|
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 |
|