iaik.cms.attributes
Class CMSMessageDigest

java.lang.Object
  extended by iaik.asn1.structures.AttributeValue
      extended by iaik.cms.attributes.CMSMessageDigest
All Implemented Interfaces:
ASN1Type

public class CMSMessageDigest
extends AttributeValue

The CMS MessageDigest attribute.

The Cryptographic Message Syntax (CMS) (RFC 5652) specifies the MessageDigest attribute to be included as an signed attribute in a SignerInfo or as an authenticated attribute in a AuthenticatedData for representing the hash value computed on the content data:

 MessageDigest ::= OCTET STRING

 id-messageDigest OBJECT IDENTIFIER ::= { iso(1) member-body(2)
         us(840) rsadsi(113549) pkcs(1) pkcs9(9) 4 }

 
As soon as there are any signed (or authenticated) attributes are present, the MessageDigest attribute has to be included to "keep" the original hash computed on the content data. Note that when signed attributes are present in fact two hash values are calculated: the first one over the content data (giving the value of the MessageDigest attribute) and the second one over the DER encoding of the signed attributes (giving the final signature value itself).

When creating a CMSMessageDigest attribute the hash value has to be supplied:

 byte[] digest = ...;
 CMSMessageDigest messageDigest = new CMSMessageDigest(digest);
 

See Also:
SignerInfo

Field Summary
static ObjectID oid
          The attributeType object identifier of the CMS MessageDigest attribute.
 
Constructor Summary
CMSMessageDigest()
          Empty default constructor.
CMSMessageDigest(ASN1Object obj)
          Creates an CMS MessageDigest from its ASN.1 representation.
CMSMessageDigest(byte[] digest)
          Creates a CMS MessageDigest for the given digest value.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 CMSMessageDigest object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this CMSMessageDigest to the specified object.
 ObjectID getAttributeType()
          Returns the OID identifying the CMSMessageDigest attribute type.
 byte[] getDigest()
          Returns the digest value.
 int hashCode()
          Returns a hashcode for this object.
 boolean multipleAllowed()
          Returns false since only one AttributeValue is allowed in the SET OF AttributeValue of an MessageDigest attribute.
 ASN1Object toASN1Object()
          Returns this CMSMessageDigest as ASN1Object.
 java.lang.String toString()
          Returns a string representation of this CMSMessageDigest.
 
Methods inherited from class iaik.asn1.structures.AttributeValue
getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

oid

public static final ObjectID oid
The attributeType object identifier of the CMS MessageDigest attribute. The corresponding OID string is "1.2.840.113549.1.9.4".

Constructor Detail

CMSMessageDigest

public CMSMessageDigest()
Empty default constructor. Required for dynamic object creation. Shall NOT be used by an application.


CMSMessageDigest

public CMSMessageDigest(byte[] digest)
Creates a CMS MessageDigest for the given digest value.

Parameters:
digest - the digest value

CMSMessageDigest

public CMSMessageDigest(ASN1Object obj)
Creates an CMS MessageDigest from its ASN.1 representation.

Parameters:
obj - the CMS MessageDigest as ASN1Object
Method Detail

getDigest

public byte[] getDigest()
Returns the digest value.

Returns:
the digest value

equals

public boolean equals(java.lang.Object obj)
Compares this CMSMessageDigest to the specified object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare this CMSMessageDigest against.
Returns:
true, if the given object is equal to this CMSMessageDigest, false otherwise

hashCode

public int hashCode()
Returns a hashcode for this object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for this object

decode

public void decode(ASN1Object obj)
Decodes the given ASN.1 CMSMessageDigest object for parsing the internal structure.

Parameters:
obj - the CMSMessageDigest as ASN1Object

toASN1Object

public ASN1Object toASN1Object()
Returns this CMSMessageDigest as ASN1Object.

Returns:
this CMSMessageDigest as ASN1Object

getAttributeType

public ObjectID getAttributeType()
Returns the OID identifying the CMSMessageDigest attribute type.

Specified by:
getAttributeType in class AttributeValue
Returns:
the OID identifying the CMSMessageDigest attribute type.

multipleAllowed

public boolean multipleAllowed()
Returns false since only one AttributeValue is allowed in the SET OF AttributeValue of an MessageDigest attribute.

Overrides:
multipleAllowed in class AttributeValue
Returns:
false since only one attribute value is allowed

toString

public java.lang.String toString()
Returns a string representation of this CMSMessageDigest.

Specified by:
toString in class AttributeValue
Returns:
this CMSMessageDigest as string

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

IAIK-CMS 6.0, (c) 2002 IAIK, (c) 2003, 2023 SIC