XCMS Toolkit

examples
Class EncryptedData3DESExample

java.lang.Object
  extended by examples.EncryptedData3DESExample

public class EncryptedData3DESExample
extends java.lang.Object

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
 

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

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

EncryptedData3DESExample

public EncryptedData3DESExample()
Default constructor for EncryptedData3DESExample.

Method Detail

showMarkup

public void showMarkup()
                throws java.lang.Exception
Executes the EncryptedData example and displays the results of XER and cryptographic processing on the console.

Throws:
java.lang.Exception

showBinary

public void showBinary()
                throws java.lang.Exception
Executes the EncryptedData example and displays the results of DER and cryptographic processing on the console.

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. Note that any command line arguments are ignored.

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

XCMS Toolkit


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