|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectexamples.NamedKeyEncryptedDataAESExample
public class NamedKeyEncryptedDataAESExample
This example program creates a value of ASN.1 type NamedKeyEncryptedData
as defined in the ISO 22895 Cryptographic Syntax Schema standard. Two methods,
named showXML and showBinary, are used to demonstrate
use of the XML Encoding Rules (XER) and Distinguished Encoding Rules (DER) of ASN.1.
A plaintext payload is encrypted, and used to encode a value of ASN.1
type NamedKeyEncryptedData. This encoded value is then decoded, and the
ciphertext is decrypted to recover the plaintext. The recovered plaintext
is then compared with the initial plaintext payload to determine if the
process worked as expected, and the initial and recovered plaintext values
are identical.
The optional unprotectedAttrs component of NamedKeyEncryptedData is
never present and is not used in this example. Version zero (v0) of the message syntax is used,
and the optional keyName and unprotectedAttrs component of type
NamedKeyEncryptedData is present. The optional unprotectedAttrs
component of type NamedKeyEncryptedData is absent, as there are no unprotected
attributes included in this example CMS message.
The encryptedContentInfo component of type NamedKeyEncryptedData is
a value of type EncryptedContentInfo whose optional encryptedContent
component is present and not "detached".
The contentEncryptionAlgorithm component of type EncryptedContentInfo
is a value of type ContentEncryptionAlgorithmIdentifier, which is set
to use the AES-128 encryption scheme in Cipher Block Chaining (CBC) mode
identifier and algorithm parameters of ASN.1 type AES-IV, a sixteen octet
value of type OCTET STRING. The contentType component indicates that
ordinary data is encrypted.
NamedKeyEncryptedData ::= SEQUENCE {
version Version (v0, ...),
keyName, [0] OCTET STRING OPTIONAL,
encryptedContentInfo EncryptedContentInfo,
unprotectedAttrs [1] UnprotectedAttributes OPTIONAL
}
EncryptedContentInfo ::= SEQUENCE {
contentType ContentType,
contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL
}
| Constructor Summary | |
|---|---|
NamedKeyEncryptedDataAESExample()
Default constructor for NamedKeyEncryptedDataAESExample. |
|
| 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 NamedKeyEncryptedData example and
displays the results of DER and cryptographic processing on
the console. |
void |
showXML()
Creates an example XCMS NamedKeyEncryptedData
message using AES. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NamedKeyEncryptedDataAESExample()
NamedKeyEncryptedDataAESExample.
| Method Detail |
|---|
public void showXML()
throws java.lang.Exception
NamedKeyEncryptedData
message using AES.
java.lang.Exception
public void showBinary()
throws java.lang.Exception
NamedKeyEncryptedData 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 | ||||||||