IAIK TSP
version 2.01

iaik.tsp
Class MessageImprint

java.lang.Object
  extended byiaik.tsp.MessageImprint

public class MessageImprint
extends Object

This class implements the TSP ASN.1 type MessageImprint as it is specified in RFC 3161.

 MessageImprint ::= SEQUENCE {
     hashAlgorithm    AlgorithmIdentifier,
     hashedMessage    OCTET STRING
 }
 

This class handles the ASN.1 structure and the DER encoding and decoding of this structure.


Constructor Summary
MessageImprint(iaik.asn1.structures.AlgorithmID hash_algorithm, byte[] hashed_message)
          To construct a new MessageImprint object, an AlgorithmID object and the corresponding hash code must be provided.
MessageImprint(iaik.asn1.ASN1Object component)
          This constructor tries to reconstruct a MessageImprint object from a given ASN.1 structure.
 
Method Summary
static byte[] calculateHash(byte[] toBeHashed, iaik.asn1.structures.AlgorithmID hashAlgorithm)
          This method calculates the hash value of the given data.
 boolean equals(Object obj)
          Compare two MessageImprint objects.
 byte[] getEncoded()
          This method DER encodes the ASN.1 MessageImprint object.
 iaik.asn1.structures.AlgorithmID getHashAlgorithm()
          This method returns the AlgorithmID object.
 byte[] getHashedMessage()
          This method returns the hashed message.
 void setHashAlgorithm(iaik.asn1.structures.AlgorithmID hash_algorithm)
          Sets the hash algorithm to be used.
 void setHashedMessage(byte[] hashed_message)
          Sets the hashed message.
 iaik.asn1.ASN1Object toASN1Object()
          Returns the ASN.1 structure of the MessageImprint object.
 String toString()
          This method returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageImprint

public MessageImprint(iaik.asn1.structures.AlgorithmID hash_algorithm,
                      byte[] hashed_message)
               throws NullPointerException
To construct a new MessageImprint object, an AlgorithmID object and the corresponding hash code must be provided.

Parameters:
hash_algorithm - A one-way collision resistant hash algorithm.
hashed_message - The hashed message.
Throws:
NullPointerException - Thrown if one of the arguments is null.

MessageImprint

public MessageImprint(iaik.asn1.ASN1Object component)
               throws iaik.asn1.CodingException
This constructor tries to reconstruct a MessageImprint object from a given ASN.1 structure.

Parameters:
component - ASN.1 structure to reconstruct.
Throws:
iaik.asn1.CodingException - Thrown if the given ASN1Object is not a MessageImprint ASN.1 object.
Method Detail

getEncoded

public byte[] getEncoded()
This method DER encodes the ASN.1 MessageImprint object.

Returns:
DER encoded MessageImprint object.

toASN1Object

public iaik.asn1.ASN1Object toASN1Object()
Returns the ASN.1 structure of the MessageImprint object.

Returns:
ASN1Object of the MessageImprint object.

equals

public boolean equals(Object obj)
Compare two MessageImprint objects.

Parameters:
obj - Object to compare with.
Returns:
True if x==y otherwise false.

setHashAlgorithm

public void setHashAlgorithm(iaik.asn1.structures.AlgorithmID hash_algorithm)
                      throws NullPointerException
Sets the hash algorithm to be used.

Parameters:
hash_algorithm - The used hash algorithm.
Throws:
NullPointerException - If the given parameter is null.

getHashAlgorithm

public iaik.asn1.structures.AlgorithmID getHashAlgorithm()
This method returns the AlgorithmID object.

Returns:
The stored AlgorithmID object or null.

setHashedMessage

public void setHashedMessage(byte[] hashed_message)
Sets the hashed message.

Parameters:
hashed_message - The hashed message.

getHashedMessage

public byte[] getHashedMessage()
This method returns the hashed message.

Returns:
the hashed message.

toString

public String toString()
This method returns a string representation of this object.

Returns:
a string representing the MessageImprint object.

calculateHash

public static byte[] calculateHash(byte[] toBeHashed,
                                   iaik.asn1.structures.AlgorithmID hashAlgorithm)
                            throws NoSuchAlgorithmException,
                                   NullPointerException
This method calculates the hash value of the given data.

Parameters:
toBeHashed - The data to be hashed.
hashAlgorithm - The used hash algorithm.
Returns:
The hashed data
Throws:
NoSuchAlgorithmException - Thrown if the given algorithm is not supported.
NullPointerException - Thrown if one of the arguments is null.

This Javadoc may contain text parts from IETF Internet Standard specifications (see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note).

IAIK TSP, © 2002-2004 IAIK, © 2004 Stiftung SIC