|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectexamples.EncryptedDataAESDetachedExample
public class EncryptedDataAESDetachedExample
This example program creates an XML encoded value of ASN.1 type
EncryptedData using the canonical XML Encoding Rules
of ASN.1 (CXER). A value is encrypted using an AES Content Encryption
Key (CEK). The encrypted content is "detached" and not present in
the encoded message.
Plaintext is encrypted, then a value type EncryptedData, is
encoded. The encoded CMS message is then decoded, and the decoded result's
decrypted value is compared with the initial plaintext value to determine
if the encryption-decryption and encoding-decoding processes worked as
expected.
This example generates a fresh 128 bit AES key and uses this key.
ASN.1 type EncryptedData is defined in ISO 22895 and IETF
RFC 3852:2004 as:
EncryptedData ::= SEQUENCE {
version CMSVersion,
encryptedContentInfo EncryptedContentInfo,
unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL
}
EncryptedContentInfo ::= SEQUENCE {
contentType ContentType,
contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL
}
ContentType ::= CONTENTS.&id({Contents}) -- OBJECT IDENTIFIER
ContentEncryptionAlgorithmIdentifier ::= SEQUENCE {
algorithm ALGORITHM.&id({ContentEncryptionAlgorithms}),
parameters ALGORITHM.&Type({ContentEncryptionAlgorithms}{@algorithm}) OPTIONAL
}
ContentEncryptionAlgorithms ALGORITHM ::= {
... -- Expect additional content encryption alogorithm objects --
}
EncryptedContent ::= OCTET STRING
| Constructor Summary | |
|---|---|
EncryptedDataAESDetachedExample()
Default constructor for EncryptedDataAESDetachedExample. |
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
Main allows this class to be run as an application from the command line. |
void |
showBinary()
Executes the EncryptedData example and displays the
results of DER and cryptographic processing on the console. |
void |
showMarkup()
Executes the EncryptedData example and displays the
results of XER and cryptographic processing on the console. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EncryptedDataAESDetachedExample()
EncryptedDataAESDetachedExample.
| Method Detail |
|---|
public void showMarkup()
throws java.lang.Exception
EncryptedData example and displays the
results of XER and cryptographic processing on the console. The
encrypted content is "detached" and not present in the message.
java.lang.Exception
public void showBinary()
throws java.lang.Exception
EncryptedData example and displays the
results of DER and cryptographic processing on the console.
java.lang.Exceptionpublic static void main(java.lang.String[] args)
args - command line arguments (not used).
|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||