XCMS Toolkit

com.cms.crypto
Class NamedKeyEncryptedDataProcessor

java.lang.Object
  extended by com.cms.crypto.NamedKeyEncryptedDataProcessor

public class NamedKeyEncryptedDataProcessor
extends java.lang.Object

Creates a NamedKeyEncryptedData object using a symmetrical encryption algorithm and a secret key. Decrypts the contents of NamedKeyEncryptedData.

ASN.1 type NamedKeyEncryptedData is defined in ISO 22895 Cryptographic Syntax Scheme as:

   NamedKeyEncryptedData ::= SEQUENCE {
        version                   CMSVersion,
      keyName               [0] OCTET STRING (SIZE(1..MAX))  OPTIONAL,
      encryptedContentInfo  EncryptedContentInfo,
      unprotectedAttrs      [1] UnprotectedAttributes  OPTIONAL
   }  
   
   EncryptedContentInfo ::= SEQUENCE {
      contentType                 ContentType,
      contentEncryptionAlgorithm  ContentEncryptAlgorithmIdentifier,
      encryptedContent            [0] EncryptedContent  OPTIONAL
   }
   
   UnprotectedAttributes ::= SET SIZE(1..MAX) OF Attribute {{Unprotected}}
   
   Unprotected ATTRIBUTE ::= {
      ...  -- Expect additional objects --
   }
   
   Attribute { ATTRIBUTE:IOSet } ::= SEQUENCE {
      attrType   ATTRIBUTE.&id({IOSet}),
      atrValues  SET OF ATTRIBUTE.&Type({IOSet}{@type})
   }
   

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

Constructor Summary
NamedKeyEncryptedDataProcessor(CMSVersion version, Codec codec)
          Constructor for NamedKeyEncryptedDataProcessor with initialization parameters for the syntax version of ASN.1 type NamedKeyEncryptedData and the ASN.1 encoding rules to be used for encoding and decoding values.
 
Method Summary
 NamedKeyEncryptedData createDetached(byte[] keyName, ContentType contentType, ContentEncryptionAlgorithmIdentifier algorithm, UnprotectedAttributes unprotectedAttributes)
          Creates a value of ASN.1 type NamedKeyEncryptedData whose encrypted content is "detached", and not present in the value of ASN.1 type EncryptedContentInfo message component.
 byte[] decrypt(byte[] ciphertext, NamedKeyEncryptedData namedKeyEncryptedData, javax.crypto.SecretKey key)
          Decrypts ciphertext associated with a value of ASN.1 type NamedKeyEncryptedData in which the optional encryptedContent component of ASN.1 type EncryptedContentInfois absent in the NamedKeyEncryptedData value, and must be provided by the caller.
 byte[] decrypt(NamedKeyEncryptedData namedKeyEncryptedData, javax.crypto.SecretKey key)
           
 byte[] decrypt(NamedKeyEncryptedData namedKeyEncryptedData, SecretKeyLookup keyLookup)
          Decrypts the encrypted payload in a value of CMS type NamedKeyEncryptedData.
 NamedKeyEncryptedData encrypt(byte[] content, byte[] keyName, ContentType contentType, ContentEncryptionAlgorithmIdentifier algorithm, javax.crypto.SecretKey key, UnprotectedAttributes unprotectedAttributes)
          Creates a value of ASN.1 type NamedKeyEncryptedData whose encrypted content is present in the value of its ASN.1 type EncryptedContentInfo message component.
 byte[] encryptDetached(byte[] content, ContentEncryptionAlgorithmIdentifier algorithm, javax.crypto.SecretKey key)
          Encrypts the detached content of a value of ASN.1 type NamedKeyEncryptedData using the specified content encryption algorithm and the provided named secret Content Encryption Key CEK), and returns the ciphertext results of encrypting the content to the caller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedKeyEncryptedDataProcessor

public NamedKeyEncryptedDataProcessor(CMSVersion version,
                                      Codec codec)
Constructor for NamedKeyEncryptedDataProcessor with initialization parameters for the syntax version of ASN.1 type NamedKeyEncryptedData and the ASN.1 encoding rules to be used for encoding and decoding values.

Parameters:
version - syntax version of ASN.1 type NamedKeyEncryptedData
codec - ASN.1 encoding rules to be used for encoding and decoding
Method Detail

encrypt

public NamedKeyEncryptedData encrypt(byte[] content,
                                     byte[] keyName,
                                     ContentType contentType,
                                     ContentEncryptionAlgorithmIdentifier algorithm,
                                     javax.crypto.SecretKey key,
                                     UnprotectedAttributes unprotectedAttributes)
                              throws CryptoException
Creates a value of ASN.1 type NamedKeyEncryptedData whose encrypted content is present in the value of its ASN.1 type EncryptedContentInfo message component.

Encrypts the data to be encrypted (content) using the encryption algorithm and any associated parameters, and a secret Content Encryption Key (CEK). The content to be encrypted may be ordinary data, or one of the CMS types supported by this toolkit, such as SignedData.

Returns a NamedKeyEncryptedData object that contains the encrypted content.

Parameters:
content - data to be encrypted
contentType - the CMS type of content to be encrypted (Data,
keyName - a string that identifies the Content Encryption Key (CEK)
algorithm - encryption algorithm and any associated parameters
key - secret key compatible with the specified encryption algorithm
unprotectedAttributes - attributes that are not part of the cryptographic message, that get transferred in the message
Returns:
a value of ASN.1 type NamedKeyEncryptedData
Throws:
CryptoException

decrypt

public byte[] decrypt(NamedKeyEncryptedData namedKeyEncryptedData,
                      SecretKeyLookup keyLookup)
               throws CryptoException
Decrypts the encrypted payload in a value of CMS type NamedKeyEncryptedData.

Parameters:
namedKeyEncryptedData - a value of ASN.1 type NamedKeyEncryptedData in its encoded form
keyLookup - simulates named key look up facillity
Returns:
the decrypted named key encrypted data
Throws:
CryptoException

decrypt

public byte[] decrypt(NamedKeyEncryptedData namedKeyEncryptedData,
                      javax.crypto.SecretKey key)
               throws CryptoException
Throws:
CryptoException

createDetached

public NamedKeyEncryptedData createDetached(byte[] keyName,
                                            ContentType contentType,
                                            ContentEncryptionAlgorithmIdentifier algorithm,
                                            UnprotectedAttributes unprotectedAttributes)
                                     throws CryptoException
Creates a value of ASN.1 type NamedKeyEncryptedData whose encrypted content is "detached", and not present in the value of ASN.1 type EncryptedContentInfo message component.

Parameters:
contentType - the CMS type of content to be encrypted (Data, EncryptedData, DigestedData, etc.)
algorithm - encryption algorithm and any associated parameters
unprotectedAttributes - attributes that are not part of the cryptographic message, that get transferred in the message
Returns:
a value of ASN.1 type NamedKeyEncryptedData that does NOT contain encrypted content
Throws:
CryptoException

encryptDetached

public byte[] encryptDetached(byte[] content,
                              ContentEncryptionAlgorithmIdentifier algorithm,
                              javax.crypto.SecretKey key)
                       throws CryptoException
Encrypts the detached content of a value of ASN.1 type NamedKeyEncryptedData using the specified content encryption algorithm and the provided named secret Content Encryption Key CEK), and returns the ciphertext results of encrypting the content to the caller. Note that the key name is not provided.

Parameters:
content - data to be encrypted
algorithm - encryption algorithm and any associated parameters
key - secret key compatible with the specified encryption algorithm
Returns:
the ciphertext results of encrypting the provided content using the specified content encryption algorithm and provided Content Encryption Key (CEK)
Throws:
CryptoException

decrypt

public byte[] decrypt(byte[] ciphertext,
                      NamedKeyEncryptedData namedKeyEncryptedData,
                      javax.crypto.SecretKey key)
               throws CryptoException,
                      EncodingException
Decrypts ciphertext associated with a value of ASN.1 type NamedKeyEncryptedData in which the optional encryptedContent component of ASN.1 type EncryptedContentInfois absent in the NamedKeyEncryptedData value, and must be provided by the caller.

Parameters:
ciphertext - the detached encrypted content
namedKeyEncryptedData - the CMS type whose encrypted content is to be decrypted
key - the secret key that was employed to encrypt the content
Returns:
the decrypted content
Throws:
CryptoException
EncodingException

XCMS Toolkit


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