|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectexamples.EncryptedData3DESExample
public class EncryptedData3DESExample
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 Triple DES Content
Encryption Key (CEK). The same example is then repeated using the
canonical Distinguished Encoding Rules (DER).
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 168 bit Triple DES key and uses this key in CBC mode.
ASN.1 type EncryptedData is defined in 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 | |
|---|---|
EncryptedData3DESExample()
Default constructor for EncryptedData3DESExample. |
|
| 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 EncryptedData3DESExample()
EncryptedData3DESExample.
| Method Detail |
|---|
public void showMarkup()
throws java.lang.Exception
EncryptedData example and displays the
results of XER and cryptographic processing on the console.
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 | ||||||||