public class MessageImprint extends java.lang.Object implements ASN1Type
MessageImprint ::= SEQUENCE {
hashAlgorithm AlgorithmIdentifier,
hashedMessage OCTET STRING
}
The length of hashedMessage MUST match the length of hash values produced by hashAlgorithm (e.g., 20 bytes for SHA-1 or 16 bytes for MD5).
The hash algorithm indicated in the hashAlgorithm field SHOULD be a known hash algorithm (one-way and collision resistant). That means that it SHOULD be one-way and collision resistant. The Time Stamp Authority SHOULD check whether or not the given hash algorithm is known to be "sufficient" (based on the current state of knowledge in cryptanalysis and the current state of the art in computational resources, for example). If the TSA does not recognize the hash algorithm or knows that the hash algorithm is weak (a decision left to the discretion of each individual TSA), then the TSA SHOULD refuse to provide the time-stamp token by returning a pkiStatusInfo of 'bad_alg'.
| Constructor and Description |
|---|
MessageImprint(AlgorithmID hashAlgorithm)
Creates a new
MessageImprint object with the specified
hash algorithm and an empty hashed message. |
MessageImprint(AlgorithmID hashAlgorithm,
byte[] hashedMessage)
Creates a new
MessageImprint object with the specified
components. |
MessageImprint(ASN1Object obj)
Creates a new
MessageImprint object from an
ASN1Object. |
| Modifier and Type | Method and Description |
|---|---|
void |
calculateHashedMessage(byte[] message)
Sets the hash of the message by calculating the hash over the message
indicated.
|
void |
calculateHashedMessage(java.io.InputStream message)
Sets the hash of the message by calculating the hash over the message
indicated.
|
void |
decode(ASN1Object obj)
Decodes a MessageImprint object from an
ASN1Object. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.
|
AlgorithmID |
getHashAlgorithm()
Returns the hash algorithm that was used to create the hash of the message.
|
byte[] |
getHashedMessage()
Returns the hash of the message.
|
int |
hashCode()
Returns a hash code value for the object.
|
ASN1Object |
toASN1Object()
Encodes this
MessageImprint object as an
ASN1Object. |
java.lang.String |
toString()
Creates a text representation of the ASN.1 structure of this
MessageImprint object. |
public MessageImprint(AlgorithmID hashAlgorithm) throws java.lang.IllegalArgumentException
MessageImprint object with the specified
hash algorithm and an empty hashed message.hashAlgorithm - the hash algorithm that was used to create the hash of the messagejava.lang.IllegalArgumentException - thrown if the parameter is nullpublic MessageImprint(AlgorithmID hashAlgorithm, byte[] hashedMessage) throws java.lang.IllegalArgumentException
MessageImprint object with the specified
components.hashAlgorithm - the hash algorithm that was used to create the hash of the messagehashedMessage - the hash of the messagejava.lang.IllegalArgumentException - thrown if any of the parameters are nullpublic MessageImprint(ASN1Object obj) throws CodingException, java.lang.IllegalArgumentException
MessageImprint object from an
ASN1Object.
The ASN1Object must be a MessageImprint structure.
obj - the ASN.1 representation of a MessageImprint structureCodingException - thrown if an errors occurs while decoding the ANS1Objectjava.lang.IllegalArgumentException - thrown if the parameter is nullpublic AlgorithmID getHashAlgorithm()
public byte[] getHashedMessage()
public void calculateHashedMessage(byte[] message)
throws java.lang.SecurityException,
java.lang.IllegalArgumentException
message - the message to be hashedjava.lang.SecurityException - thrown if the hash algorithm is not implemented by any of the
installed JCA providersjava.lang.IllegalArgumentException - thrown if the parameter is nullpublic void calculateHashedMessage(java.io.InputStream message)
throws java.io.IOException,
java.lang.SecurityException,
java.lang.IllegalArgumentException
message - contains the message to be hashedjava.io.IOException - thrown if an error occurred while reading the message from the
input streamjava.lang.SecurityException - thrown if the hash algorithm is not implemented by any of the
installed JCA providersjava.lang.IllegalArgumentException - thrown if the parameter is nullpublic void decode(ASN1Object obj) throws CodingException, java.lang.IllegalArgumentException
ASN1Object.
The ASN1Object must contain a MessageImprint structure.
decode in interface ASN1Typeobj - an ASN.1 representation of a MessageImprint structureCodingException - thrown if an errors occurs while decoding the ANS1Objectjava.lang.IllegalArgumentException - thrown if the parameter is nullpublic ASN1Object toASN1Object()
MessageImprint object as an
ASN1Object.toASN1Object in interface ASN1Typepublic java.lang.String toString()
MessageImprint object.toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
Two MessageImprint objects are equal only if their components
are equal.
equals in class java.lang.Objectobj - the reference object with which to comparetrue if the objects are "equal"; false
otherwisepublic int hashCode()
hashCode in class java.lang.Object