public class PKCS7CMSEnvelopedDataDemo extends java.lang.Object
Constructor and Description |
---|
PKCS7CMSEnvelopedDataDemo()
Setup the demo certificate chains.
|
Modifier and Type | Method and Description |
---|---|
iaik.asn1.ASN1Object |
createEnvelopedData(byte[] message)
Creates a CMS
EnvelopedData message. |
byte[] |
createEnvelopedDataStream(byte[] message)
Creates a CMS
EnvelopedDataStream message. |
iaik.asn1.ASN1Object |
createPKCS7EnvelopedData(byte[] message)
Creates a PKCS#7
EnvelopedData message. |
byte[] |
createPKCS7EnvelopedDataStream(byte[] message)
Creates a PKCS#7
EnvelopedDataStream message. |
byte[] |
getEnvelopedData(iaik.asn1.ASN1Object obj,
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. |
byte[] |
getPKCS7EnvelopedData(iaik.asn1.ASN1Object obj,
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[] |
getPKCS7EnvelopedDataStream(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.
|
public PKCS7CMSEnvelopedDataDemo() 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.
The enveloped-data content type consists of encrypted content of any type and encrypted content-encryption keys for one or more recipients. The combination of encrypted content and encrypted content-encryption key for a recipient is a "digital envelope" for that recipient. Any type of content can be enveloped for any number of recipients in parallel.
message
- the message to be enveloped, as byte representationEnvelopedData
object just creatediaik.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
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 belongsiaik.cms.CMSException
- if the message cannot be recoveredjava.io.IOException
- if an I/O error occurspublic iaik.asn1.ASN1Object createEnvelopedData(byte[] message) throws iaik.cms.CMSException
EnvelopedData
message.
The enveloped-data content type consists of encrypted content of any type and encrypted content-encryption keys for one or more recipients. The combination of encrypted content and encrypted content-encryption key for a recipient is a "digital envelope" for that recipient. Any type of content can be enveloped for any number of recipients in parallel.
message
- the message to be enveloped, as byte representationEnvelopedData
as ASN.1 objectiaik.cms.CMSException
- if the EnvelopedData
object cannot
be createdpublic byte[] getEnvelopedData(iaik.asn1.ASN1Object obj, java.security.PrivateKey privateKey, int recipientInfoIndex) throws iaik.cms.CMSException
EnvelopedData
object for the
specified recipient and returns the decrypted (= original) message.obj
- the EnvelopedData
as ASN.1 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 recoveredpublic byte[] createPKCS7EnvelopedDataStream(byte[] message) throws iaik.pkcs.PKCSException, java.io.IOException
EnvelopedDataStream
message.
The enveloped-data content type consists of encrypted content of any type and encrypted content-encryption keys for one or more recipients. The combination of encrypted content and encrypted content-encryption key for a recipient is a "digital envelope" for that recipient. Any type of content can be enveloped for any number of recipients in parallel.
message
- the message to be enveloped, as byte representationEnvelopedData
object just creatediaik.pkcs.PKCSException
- if the EnvelopedData
object cannot
be createdjava.io.IOException
- if an I/O error occurspublic byte[] getPKCS7EnvelopedDataStream(byte[] encoding, java.security.PrivateKey privateKey, int recipientInfoIndex) throws iaik.pkcs.PKCSException, java.io.IOException
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 belongsiaik.pkcs.PKCSException
- if the message cannot be recoveredjava.io.IOException
- if an I/O error occurspublic iaik.asn1.ASN1Object createPKCS7EnvelopedData(byte[] message) throws iaik.pkcs.PKCSException, java.io.IOException
EnvelopedData
message.
The enveloped-data content type consists of encrypted content of any type and encrypted content-encryption keys for one or more recipients. The combination of encrypted content and encrypted content-encryption key for a recipient is a "digital envelope" for that recipient. Any type of content can be enveloped for any number of recipients in parallel.
message
- the message to be enveloped, as byte representationEnvelopedData
as ASN.1 objectiaik.pkcs.PKCSException
- if the EnvelopedData
object cannot
be createdjava.io.IOException
- if an I/O error occurspublic byte[] getPKCS7EnvelopedData(iaik.asn1.ASN1Object obj, java.security.PrivateKey privateKey, int recipientInfoIndex) throws iaik.pkcs.PKCSException, java.io.IOException
EnvelopedData
object for the
specified recipient and returns the decrypted (= original) message.obj
- the EnvelopedData
as ASN.1 objectprivateKey
- the private key to decrypt the messagerecipientInfoIndex
- the index into the RecipientInfo
array
to which the specified private key belongsiaik.pkcs.PKCSException
- 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 filesjava.lang.Exception