XCMS Toolkit

examples
Class NamedKeyEncryptedDataAESDetachedExample

java.lang.Object
  extended by examples.NamedKeyEncryptedDataAESDetachedExample

public class NamedKeyEncryptedDataAESDetachedExample
extends java.lang.Object

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
 }
 

Version:
1.00 - 2006/02/22
Author:
support@phillipgriffin.com

Constructor Summary
NamedKeyEncryptedDataAESDetachedExample()
          Default constructor for NamedKeyEncryptedDataAESDetachedExample.
 
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 with detached encrypted content using AES.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedKeyEncryptedDataAESDetachedExample

public NamedKeyEncryptedDataAESDetachedExample()
Default constructor for NamedKeyEncryptedDataAESDetachedExample.

Method Detail

showXML

public void showXML()
             throws java.lang.Exception
Creates an example XCMS NamedKeyEncryptedData message with detached encrypted content using AES.

Throws:
java.lang.Exception

showBinary

public void showBinary()
                throws java.lang.Exception
Executes the NamedKeyEncryptedData example and displays the results of DER and cryptographic processing on the console. The encrypted content is detached.

Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
Main allows this class to be run as an application from the command line.

Parameters:
args - command line arguments (not used).

XCMS Toolkit


Copyright © 2005-2006 GRIFFIN Consulting. All Rights Reserved.