iaik.smime.ess
Class MsgSigDigest

java.lang.Object
  extended by iaik.asn1.structures.AttributeValue
      extended by iaik.smime.ess.ESSAttributeValue
          extended by iaik.smime.ess.MsgSigDigest
All Implemented Interfaces:
ASN1Type

public class MsgSigDigest
extends ESSAttributeValue

The S/MIMEv3 ESS MsgSigDigest attribute.

The Enhanced Security Services for S/MIMEv3 (ESS) (RFC 2634) specifies the MsgSigDigest attribute to be included as an signed attribute in a SignerInfo created by an recipient when answering to a ReceiptRequest by sending a signed receipt back to the originator:

 msgSigDigest ::= OCTET STRING

 id-aa-msgSigDigest OBJECT IDENTIFIER ::= { iso(1) member-body(2)
    us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) id-aa(2) 5}
 
When verifying the signature of a SignerInfo containing signed attributes a hash has to be calculated over the DER encoding of the signed attributes to be verified against the signature value. When the originator has requested a signed receipt the hash value calculated above forms the value of a MsgSigDigest attribute to be sent back to the originator as signed attribute. The originator when verifying a Signed Receipt compares the message signature digest value (kept from the original message or calculated again) with the value of the msgSigDigest signedAttribute included in the signedData/Receipt signerInfo. If these digest values are identical, then that proves that the message signature digest value calculated by the recipient based on the received original signedData object is the same as that calculated by the sender. This proves that the recipient received exactly the same original signedData content and signedAttributes as sent by the sender because that is the only way that the recipient could have calculated the same message signature digest value as calculated by the sender. If the digest values are different, then the signedData/Receipt signature verification process fails.

This class provides two constructors for creating a new MsgSigDigest. The first one allows to immediately set the digest value:

 byte[] digest = ...;
 MsgSigDigest msgSigDigest = new MsgSigDigest(digest);
 
The second constructor may be used to create MsgSigDigest attribute immediately from a SignerInfo object:
 SignerInfo signerInfo = ...;
 MsgSigDigest msgSigDigest = new MsgSigDigest(signerInfo);
 

See Also:
ReceiptRequest, Receipt, SignerInfo

Field Summary
static ObjectID oid
          The attributeType object identifier of this MsgSigDigest attribute.
 
Constructor Summary
MsgSigDigest()
          Empty default constructor.
MsgSigDigest(ASN1Object obj)
          Creates an MsgSigDigest from its ASN.1 representation.
MsgSigDigest(byte[] digest)
          Creates an MsgSigDigest for the given digest value.
MsgSigDigest(SignerInfo signerInfo)
          Creates a MsgSigDigest from the given SignerInfo.
MsgSigDigest(SignerInfo signerInfo, SecurityProvider securityProvider)
          Creates a MsgSigDigest from the given SignerInfo.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 MsgSigDigest object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this MsgSigDigest to the specified object.
 ObjectID getAttributeType()
          Returns the OID identifying the MsgSigDigest attribute type.
 byte[] getDigest()
          Returns the digest value.
 int hashCode()
          Returns a hashcode for this object.
 ASN1Object toASN1Object()
          Returns this MsgSigDigest as ASN1Object.
 java.lang.String toString()
          Returns a string representation of this MsgSigDigest.
 
Methods inherited from class iaik.smime.ess.ESSAttributeValue
multipleAllowed
 
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 this MsgSigDigest attribute. The corresponding OID string is "1.2.840.113549.1.9.16.2.5".

Constructor Detail

MsgSigDigest

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


MsgSigDigest

public MsgSigDigest(byte[] digest)
Creates an MsgSigDigest for the given digest value.

Parameters:
digest - the digest value

MsgSigDigest

public MsgSigDigest(SignerInfo signerInfo)
             throws ESSException
Creates a MsgSigDigest from the given SignerInfo.

The value of the MsgSigDigest results from calculating a hash over the DER encoding of the signed attributes included in the given SignerInfo.

Parameters:
signerInfo - SignerInfo the SignerInfo from which to create the MsgSigDigest
Throws:
ESSException - if no signed attributes are included in the SignerInfo, or the hash algorithm to be used is not supported or an error occurs when ancoding the signed attributes

MsgSigDigest

public MsgSigDigest(SignerInfo signerInfo,
                    SecurityProvider securityProvider)
             throws ESSException
Creates a MsgSigDigest from the given SignerInfo.

The value of the MsgSigDigest results from calculating a hash over the DER encoding of the signed attributes included in the given SignerInfo.

Parameters:
signerInfo - SignerInfo the SignerInfo from which to create the MsgSigDigest
securityProvider - the SecurityProvider to be used by this object, if null use the default system-wide installed SecurityProvider; this constructor may use the SecurityProvider method getHash() to calculate the hash from the SignerInfo signed attributes
Throws:
ESSException - if no signed attributes are included in the SignerInfo, or the hash algorithm to be used is not supported or an error occurs when ancoding the signed attributes

MsgSigDigest

public MsgSigDigest(ASN1Object obj)
Creates an MsgSigDigest from its ASN.1 representation.

Parameters:
obj - the MsgSigDigest 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 MsgSigDigest to the specified object.

Specified by:
equals in class ESSAttributeValue
Parameters:
obj - the object to compare this MsgSigDigest against.
Returns:
true, if the given object is equal to this MsgSigDigest, false otherwise

hashCode

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

Overrides:
hashCode in class ESSAttributeValue
Returns:
a hashcode for this object

decode

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

Parameters:
obj - the MsgSigDigest as ASN1Object

toASN1Object

public ASN1Object toASN1Object()
Returns this MsgSigDigest as ASN1Object.

Returns:
this MsgSigDigest as ASN1Object

getAttributeType

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

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

toString

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

Specified by:
toString in class AttributeValue
Returns:
this MsgSigDigest 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