IAIK TSP
version 2.32

iaik.tsp
Class MessageImprint

java.lang.Object
  extended by iaik.tsp.MessageImprint

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

Constructor Detail

MessageImprint

public MessageImprint(AlgorithmID hash_algorithm,
                      byte[] hashed_message)
               throws java.lang.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:
java.lang.NullPointerException - Thrown if one of the arguments is null.

MessageImprint

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

Parameters:
component - ASN.1 structure to reconstruct.
Throws:
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 ASN1Object toASN1Object()
Returns the ASN.1 structure of the MessageImprint object.

Returns:
ASN1Object of the MessageImprint object.

hashCode

public int hashCode()
Returns a hash code of this MessageImprint.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare with.
Returns:
True if x==y otherwise false.

setHashAlgorithm

public void setHashAlgorithm(AlgorithmID hash_algorithm)
                      throws java.lang.NullPointerException
Sets the hash algorithm to be used.

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

getHashAlgorithm

public 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 java.lang.String toString()
This method returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
a string representing the MessageImprint object.

calculateHash

public static byte[] calculateHash(byte[] toBeHashed,
                                   AlgorithmID hashAlgorithm)
                            throws java.security.NoSuchAlgorithmException,
                                   java.lang.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:
java.security.NoSuchAlgorithmException - Thrown if the given algorithm is not supported.
java.lang.NullPointerException - Thrown if one of the arguments is null.

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

IAIK TSP, © 2002 IAIK, © 2003 - 2014 Stiftung SIC