public class VariableOutputLengthHashFunction extends java.lang.Object implements HashFunction, StandaloneRepresentable
This class uses an "inner" hash function and applies some tricks to get the output length to what is desired.
If the inner hash function is modeled as a random oracle, the resulting hash function is also a random oracle. If the inner hash function is collision resistant and the desired output length is larger than the inner hash function's output length, then the resulting hash function is also collision resistant.
| Constructor and Description |
|---|
VariableOutputLengthHashFunction(HashFunction hashFunction,
int outputLength)
Initializes this instance using a specific base hash function and output length.
|
VariableOutputLengthHashFunction(int outputLength)
Initializes this instance using the
SHA256HashFunction and the desired output length. |
VariableOutputLengthHashFunction(Representation repr)
Reconstructs the hash function from its representation
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
HashFunction |
getInnerHashFunction()
Retrieves the base hash function to use.
|
int |
getOutputLength()
Retrieves the desired output length of this hash function in number of bytes.
|
Representation |
getRepresentation()
The representation of this object.
|
byte[] |
hash(byte[] x)
Hashes a byte array using the hash function.
|
int |
hashCode() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waithash, hashpublic VariableOutputLengthHashFunction(int outputLength)
SHA256HashFunction and the desired output length.outputLength - the desired output length of this hash function in number of bytespublic VariableOutputLengthHashFunction(HashFunction hashFunction, int outputLength)
hashFunction - the base hash functionoutputLength - the desired output length of this hash function in number of bytespublic VariableOutputLengthHashFunction(Representation repr)
public HashFunction getInnerHashFunction()
public Representation getRepresentation()
RepresentableReprUtilgetRepresentation in interface RepresentableRepresentationpublic byte[] hash(byte[] x)
HashFunctionhash in interface HashFunctionx - the bytes to hashpublic int getOutputLength()
getOutputLength in interface HashFunctionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object