public class EnvelopedDataOutputStreamDemo extends java.lang.Object
EnvelopedDataOutputStream
and
for encrypting data using the CMS type EnvelopedData.Constructor and Description |
---|
EnvelopedDataOutputStreamDemo()
Setup the demo certificate chains.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
createEnvelopedDataStream(byte[] message)
Creates a CMS
EnvelopedData and wraps it into a ContentInfo. |
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)
Main method.
|
void |
start()
Starts the demo.
|
public EnvelopedDataOutputStreamDemo() throws java.io.IOException
java.io.IOException
- if an file read error occurspublic byte[] createEnvelopedDataStream(byte[] message) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
and wraps it into a ContentInfo.message
- the message to be enveloped, as byte representationiaik.cms.CMSException
- if the EnvelopedData
object cannot
be createdjava.io.IOException
- if an I/O error occurspublic byte[] getEnvelopedDataStream(byte[] encoding, java.security.PrivateKey privateKey, int recipientInfoIndex) throws iaik.cms.CMSException, java.io.IOException
encoding
- the encoded EnvelopedData object, wrapped in a ContentInfoprivateKey
- the private key to decrypt the messagerecipientInfoIndex
- the index into the RecipientInfo
array
to which the specified private key belongsiaik.cms.CMSException
- if the message cannot be recoveredjava.io.IOException
- if an I/O error occurspublic void start()
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
- if an some error occurs