public class OaepEnvelopedDataDemo extends java.lang.Object
All keys and certificates are read from a keystore created by the SetupKeyStore program.
Constructor and Description |
---|
OaepEnvelopedDataDemo()
Setup the demo certificate chains.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
createEnvelopedData(byte[] message)
Creates a CMS
EnvelopedData message. |
byte[] |
createEnvelopedDataStream(byte[] message)
Creates a CMS
EnvelopedDataStream message. |
byte[] |
getEnvelopedData(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)
Main method.
|
void |
start()
Shows thw CMS EnvelopedData implementation for
the RSA-OAEP (PKCS#1v2.1) algorithm.
|
public OaepEnvelopedDataDemo() throws java.io.IOException
java.io.IOException
- if an file read error occurspublic byte[] createEnvelopedDataStream(byte[] message) throws iaik.cms.CMSException, java.io.IOException
EnvelopedDataStream
message.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 BER encoded ContentInfo containing an EnvelopedData objectprivateKey
- 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 byte[] createEnvelopedData(byte[] message) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
message.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[] getEnvelopedData(byte[] encoding, java.security.PrivateKey privateKey, int recipientInfoIndex) throws iaik.cms.CMSException, java.io.IOException
EnvelopedData
object for the
specified recipient and returns the decrypted (= original) message.encoding
- the ContentInfo encoding holding an EnvelopedDataprivateKey
- 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.io.IOException
- if an I/O error occurs when reading required keys
and certificates from the keystore filejava.lang.Exception