com.rsa.certj.pkcs7

Class DigestedData

java.lang.Object
  |
  +--com.rsa.certj.pkcs7.ContentInfo
        |
        +--com.rsa.certj.pkcs7.DigestedData
All Implemented Interfaces:
Cloneable, Serializable

public class DigestedData
extends ContentInfo
implements Cloneable, Serializable

This class encodes and decodes the PKCS #7 DigestedData type. The digested-data content type consists of content of any type and a message digest of the content.

The ASN.1 definition is as follows:

 DigestedData ::= SEQUENCE {
   version Version,
   digestAlgorithm DigestAlgorithmIdentifier,
   contentInfo ContentInfo,
   digest Digest }

 Digest ::= OCTET STRING

The fields of type DigestedData have the following meanings:

Copyright © RSA Security Inc., 1999-2001. All rights reserved.

See Also

Serialized Form

Fields inherited from class com.rsa.certj.pkcs7.ContentInfo
DATA, DIGESTED_DATA, ENCRYPTED_DATA, ENVELOPED_DATA, NO_CONTENT, PKCS7_VERSION_NUMBER_0, PKCS7_VERSION_NUMBER_1, SIGNED_DATA
 

Constructor Summary

DigestedData(CertJ certJ, CertPathCtx pathCtx)

Creates a new object to encode or decode PKCS #7 DigestedData.

 

Method Summary

 void

clearSensitiveData()

Clears any sensitive data.

 Object

clone()

Overrides the default clone method to get a deeper clone.

 boolean

equals(Object obj)

Returns true if this object and obj contain the same DigestedData; returns false otherwise.

 String

getDigestAlgorithmName()

Gets the digest algorithm name.

 byte[]

getDigestAlgorithmOID()

Gets the digest algorithm identifier.

 byte[]

getMessageDigest()

Gets the computed message digest of the content.

 int

getVersionNumber()

Gets the PKCS #7 syntax version number.

 void

setContentInfo(ContentInfo content)

Sets the actual content data of this DigestedData object.

 void

setDigestAlgorithm(byte[] digestOID, int offset, int len)

Sets the digest algorithm identifier.

 void

setDigestAlgorithm(String algName)

Sets the digest algorithm identifier.

 void

setVersionNumber(int versionNumber)

Sets the PKCS #7 syntax version number.

 
Methods inherited from class com.rsa.certj.pkcs7.ContentInfo
bytesRead, clearInternalContentBuffer, endOfMessage, getContent, getContentInfoDERLen, getContentInfoDERLen, getContentType, getDevice, getDeviceList, getInstance, getInstance, getMessageType, getMessageType, getUnprocessedDataLen, readFinal, readInit, readInit, readInit, readUpdate, setCertJ, setCertPath, setDevice, writeMessage, writeMessage
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigestedData

public DigestedData(CertJ certJ,
                    CertPathCtx pathCtx)
Creates a new object to encode or decode PKCS #7 DigestedData.

Parameters

         certJ  

A CertJ object that contains environment information. It contains random object, and specifies the device list.

         pathCtx  

A CertPathCtx object that contains certificate path validation information. Most certification path providers require the trusted certificate component of this object to be non-empty to be able to perform certification path validation.

Method Detail

setContentInfo

public void setContentInfo(ContentInfo content)
                    throws PKCS7Exception
Sets the actual content data of this DigestedData object.

Parameters

         content  

A ContentInfo object that is digested. It can have any of the PKCS #7 defined content types.

Throws

PKCS7Exception - If this ContentInfo object cannot be cloned, or if it is null.

setVersionNumber

public void setVersionNumber(int versionNumber)
Sets the PKCS #7 syntax version number.

Parameters

         versionNumber  

The PKCS #7 syntax version number.


getVersionNumber

public int getVersionNumber()
Gets the PKCS #7 syntax version number.

Returns

version The PKCS #7 syntax version number.

setDigestAlgorithm

public void setDigestAlgorithm(String algName)
                        throws PKCS7Exception
Sets the digest algorithm identifier.

Parameters

         name  

A String that identifies the DigestAlgorithm object, for example, SHA.1.

Throws

PKCS7Exception - If specified algorithm name is null or invalid.

setDigestAlgorithm

public void setDigestAlgorithm(byte[] digestOID,
                               int offset,
                               int len)
                        throws PKCS7Exception
Sets the digest algorithm identifier.

Parameters

         DigestOID  

Tthe message-digest algorithm (and any associated parameters) under which the content is digested.

         offset  

The offset into digestOID array.

         len  

The length of digest OID data in the digestOID array.

Throws

PKCS7Exception - If the specified OID is null.

getDigestAlgorithmOID

public byte[] getDigestAlgorithmOID()
Gets the digest algorithm identifier.

Returns

The message-digest algorithm OID

getDigestAlgorithmName

public String getDigestAlgorithmName()
                              throws PKCS7Exception
Gets the digest algorithm name.

Returns

the message-digest algorithm name

Throws

PKCS7Exception - If the algorithm name cannot be obtained.

getMessageDigest

public byte[] getMessageDigest()
Gets the computed message digest of the content.

Returns

A new byte array that contains the message digest. If message digest is not computed, this method returns null.

The message digest is computed during getContentDERLen method, and the writeContent method. It is also set after reading the message.

clone

public Object clone()
             throws CloneNotSupportedException
Overrides the default clone method to get a deeper clone.

Overrides

clone in class ContentInfo

Returns

A copy of this object in its current state.

Throws

CloneNotSupportedException - If the cloning operation is not successful.

equals

public boolean equals(Object obj)
Returns true if this object and obj contain the same DigestedData; returns false otherwise.

Overrides

equals in class Object

Parameters

         obj  

An instance of the DigestedData class.

Returns

A boolean indicating whether these objects are equal.

clearSensitiveData

public void clearSensitiveData()
Clears any sensitive data. The finalizer will clear the data, but it is not known when the garbage collector will call the finalizer. This method clears all sensitive data as soon as possible.

Overrides

clearSensitiveData in class ContentInfo


RSA BSAFE ® Cert-J 2.1.1 001-047007-211-001-000