|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ostore.util.SHA1Hash
SHA1Hash is the hash class used by all entities which are SHA1 hashes. (In the prototype, this means Guids and VHashes).
Field Summary | |
protected byte[] |
_bytes
These are the bytes in this Hash. |
static SHA1Hash |
NULL_HASH
This is the null hash for SHA1 |
static byte[] |
NULL_HASH_VALUE
This is the value of the null hash for SHA1 |
static int |
NUM_BYTES
The number of bytes all SHA1Hash s are composed of |
static int |
TYPE_CODE
|
Constructor Summary | |
SHA1Hash()
default constructor (creates null hash) |
|
SHA1Hash(byte[] bytes)
hashes the given buffer to create a new SHA1Hash |
|
SHA1Hash(byte[] data,
int[] offset)
Reads the bytes of the value of this hash in from the input byte array. |
|
SHA1Hash(byte[] bytes,
int offset,
int len)
hashes the given buffer to create a new SHA1Hash |
|
SHA1Hash(Digestible d)
hashes over the input object |
|
SHA1Hash(SHA1Hash shash)
copy constructor (creates new hash with value of old hash) |
|
SHA1Hash(SHA1HashBuffer buffer)
Computes and returns the digest of the specified buffer. |
|
SHA1Hash(String s)
hashes over the bytes of the input String |
Method Summary | |
void |
add_to_digest(SecureHashBuffer buffer)
Adds this object's state to the specified SecureHashBuffer using the various add
methods. |
byte[] |
bytes()
Returns the bytes contained in this hash |
void |
calculate(byte[] bytes,
SecureVerify verification)
This routine calculates the root hash for a given object and its slice of its verification tree (basically, this routine does what verify does, but instead of comparing the last hash to this hash and returning the result, it sets this hash's value to the last hash's value) |
void |
calculate(QuickSerializable qs,
SecureVerify verify)
This routine calculates the root hash for a given object and its slice of its verification tree (basically, this routine does what verify does, but instead of comparing the last hash to this hash and returning the result, it sets this hash's value to the last hash's value) |
Object |
clone()
Create an exact copy of this hash |
int |
compareTo(Object o)
This routine compares this SHA1Hash to another
Object |
static void |
concatenateHashes(SHA1Hash hash1,
SHA1Hash hash2,
byte[] buf)
This routine concatenates two hashes and stores the result in the input byte array. |
boolean |
equals(Object other)
Compares this SecureHash with another hash, and returns true iff they are the same type of hash and have the same byte representation |
String |
fullString()
Converts all bytes of this SecureHash to a human-readable String |
void |
hash(byte[] bytes)
Hashes over the input bytes |
SecureVerify[] |
hash(byte[][] array)
Creates a hierarchical hash over an array of byte arrays, and returns an array of arrays, the i^th element of which contains the hashes along the tree of hashes to the root hash for the i^th byte array in the input array; This hash is set to the value of that root. |
void |
hash(byte[] bytes,
int offset,
int len)
Hashes over the input bytes, starting at offset, going for len |
void |
hash(Digestible o)
Hashes over a Digestible object |
SecureVerify[] |
hash(QuickSerializable[] array)
Creates a hierarchical hash over an array of QuickSerializable objects, and returns an array of arrays, the i^th element of which contains the hashes along the tree of hashes to the root hash for the i^th object in the input array; This hash is set to the value of that root. |
void |
hash(String str)
Hashes over the bytes of the input String |
int |
hashCode()
Calculates a Java hash code for this SecureHash object (by taking its lower order bytes) |
boolean |
isNull()
Determines if this SecureHash is a NULL hash or not. |
long |
lower64bits()
Calculates a Java hash code for this SecureHash object (by taking its lower order bytes) |
static void |
main(String[] args)
Used to test hashing by creating hierarchical hashes |
SecureHash |
nullHash()
Returns the implementation's NULL hash (typically all zeroes). |
int |
size()
Return the number of bytes used in the representation of this hash (for example, SHA1 uses 20 bytes) |
void |
to_bytes(byte[] data,
int[] offset)
Write the bytes of this hash to the input byte array |
String |
toString()
Converts a few bytes of this SecureHash to a human-readable String |
int |
type_code()
Return the type code of a SHA1Hash |
boolean |
verify(byte[] bytes)
Verifies that the input bytes hash to this hash value |
boolean |
verify(byte[] bytes,
int offset,
int len)
Verifies that the input bytes hash to this hash value |
boolean |
verify(byte[] bytes,
SecureVerify verification)
Verifies that the input byte array, coupled with the input verification information, hashes to this hash's value |
boolean |
verify(Digestible o)
Verifies a QuickSerializable object |
boolean |
verify(QuickSerializable o,
SecureVerify verification)
Verifies that the input object, coupled with the input verification information, hashes to this hash's value |
boolean |
verify(String str)
Verifies the input String |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int TYPE_CODE
public static final int NUM_BYTES
SHA1Hash
s are composed ofpublic static final byte[] NULL_HASH_VALUE
public static final SHA1Hash NULL_HASH
protected byte[] _bytes
Constructor Detail |
public SHA1Hash()
public SHA1Hash(SHA1Hash shash)
shash
- == old hash whose value we are to copypublic SHA1Hash(byte[] bytes)
SHA1Hash
the
- array of bytes over which to hashpublic SHA1Hash(byte[] bytes, int offset, int len)
SHA1Hash
the
- array of bytes over which to hashoffset
- in bytes at which to start hashingnumber
- of bytes over which to hashpublic SHA1Hash(byte[] data, int[] offset)
array
- out of which to read the bytes of this hashoffset
- in data at which to begin
reading. offset[0]
is incremented by
NUM_BYTES
on completion of this constructor.public SHA1Hash(String s)
string
- over which to hashpublic SHA1Hash(Digestible d)
object
- over which to hashpublic SHA1Hash(SHA1HashBuffer buffer)
buffer
- A SecureHashBuffer
.Method Detail |
public Object clone() throws CloneNotSupportedException
clone
in interface SecureHash
clone
in class Object
CloneNotSupportedException
- if clone() is not supportedpublic int compareTo(Object o) throws ClassCastException
SHA1Hash
to another
Object
compareTo
in interface Comparable
o
- SHA1Hashthis < o
, 0 if this == o
,
or 1 if this > o
.ClassCastException
- if o
is not a SHA1Hashpublic void to_bytes(byte[] data, int[] offset)
to_bytes
in interface QuickSerializable
array
- into which to write the bytes of this hashoffset
- in data at which to begin writingpublic int type_code()
type_code
in interface QuickSerializable
public int size()
size
in interface SecureHash
public boolean isNull()
isNull
in interface SecureHash
public SecureHash nullHash()
nullHash
in interface SecureHash
public byte[] bytes()
bytes
in interface SecureHash
public boolean equals(Object other)
equals
in interface SecureHash
equals
in class Object
the
- object with which to compare this SecureHashpublic int hashCode()
hashCode
in interface SecureHash
hashCode
in class Object
public long lower64bits()
public void hash(byte[] bytes, int offset, int len)
hash
in interface SecureHash
byte
- array over which to hashoffset
- in bytes[] at which to begin hashingnumber
- of bytes over which to hashpublic void hash(byte[] bytes)
hash
in interface SecureHash
byte
- array over which to hashpublic void hash(Digestible o)
hash
in interface SecureHash
the
- object over which to hashpublic void hash(String str)
hash
in interface SecureHash
the
- String over which to hashpublic static void concatenateHashes(SHA1Hash hash1, SHA1Hash hash2, byte[] buf)
hash1
- the first hash to concatenatehash2
- the second hash to concatenatebuf
- the byte array in which to storet the concatenationpublic SecureVerify[] hash(byte[][] array)
hash
in interface SecureHash
array
- of byte arrays.public SecureVerify[] hash(QuickSerializable[] array)
hash
in interface SecureHash
array
- of QuickSerializable objects.public boolean verify(byte[] bytes, int offset, int len)
verify
in interface SecureHash
byte
- array containing the bytes to verifyoffset
- in bytes[] at which to begin hashingnumber
- of bytes over which to hashpublic boolean verify(byte[] bytes)
verify
in interface SecureHash
byte
- array to verifypublic boolean verify(Digestible o)
verify
in interface SecureHash
the
- object over which to hashpublic boolean verify(String str)
verify
in interface SecureHash
the
- String to verifypublic boolean verify(byte[] bytes, SecureVerify verification)
verify
in interface SecureHash
bytes
- to verifyverification
- verification info with which to verify the bytes
against this SHA1Hashpublic boolean verify(QuickSerializable o, SecureVerify verification)
verify
in interface SecureHash
bytes
- to verifyverification
- verification info with which to verify the bytes
against this SHA1Hashpublic void calculate(byte[] bytes, SecureVerify verification)
calculate
in interface SecureHash
bytes
- bytes to calc a root hash forverification
- verification info to use in the calculationpublic void calculate(QuickSerializable qs, SecureVerify verify)
calculate
in interface SecureHash
qs
- object to calc a root hash forverify
- verification information to use in the calculationpublic String toString()
toString
in interface SecureHash
toString
in class Object
public String fullString()
fullString
in interface SecureHash
public void add_to_digest(SecureHashBuffer buffer)
Digestible
SecureHashBuffer
using the various add
methods.add_to_digest
in interface Digestible
ostore.util.Digestible
SecureHashBuffer.add( byte )
,
SecureHashBuffer.add( byte[] )
,
SecureHashBuffer.add( byte[], int, int )
,
SecureHashBuffer.add( Digestible )
public static void main(String[] args)
arguments;
- should contain one entry
which is the number of byte arrays over which
to create a hierarchical hash
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |