ostore.util
Interface VerifiableBlock

All Superinterfaces:
Cacheable, QuickSerializable
All Known Subinterfaces:
BtreeNode
All Known Implementing Classes:
Btree, Btree.InteriorNode, DataObject, DataObject.DataBlock

public interface VerifiableBlock
extends Cacheable

The VerifiableBlock interface should be implemented by all objects that need to be self-verifiable. In order to be self-verifiable, an object must maintain a field to record the fhash, the secure hash that lies at the root of the verification tree constructed from the erasure-encoded fragments produced by the archival layer. A self-verifiable object must also provide methods for computing and verifying guids and verification hashes. In computing a guid, an object should reference all information (including its fhash). In computing a vhash, however, an object should not reference any guids that are created by the archive. If the archive has not yet computed the fragments for an object, the object will lack an fhash and thus will be unable to compute or verify its own guid. If such a request is made, a BlockNotGuidVerifiableException is thrown.

Version:
$Id: VerifiableBlock.java,v 1.9 2002/07/29 18:48:54 geels Exp $
Author:
Patrick R. Eaton

Method Summary
 SecureHash computeGuid()
          Compute and return the guid of the object.
 SecureHash computeVhash()
          Compute and return the verification hash of the object.
 SecureHash getFhash()
          Return the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block.
 void setFhash(SecureHash fhash)
          Record the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block.
 void toGuidBytes(byte[] data, int[] offset)
          Serialize the object in a form suitable for computing the block guid of the object.
 void toVhashBytes(byte[] data, int[] offset)
          Serialize the object in a form suitable for computing the verification hash of the object.
 boolean verifyGuid(SecureHash bguid)
          Verify the contents of the object against its given guid.
 boolean verifyVhash(SecureHash vhash)
          Verify the contents of the object against its given verification hash.
 
Methods inherited from interface ostore.util.QuickSerializable
serialize
 

Method Detail

getFhash

public SecureHash getFhash()
Return the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block. The root hash verifies the the fragments of the block and is a component in the computation of the block GUID.

Returns:
the secure hash at the root of the verification tree

setFhash

public void setFhash(SecureHash fhash)
Record the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block. The root hash verifies the the fragments of the block and is a component in the computation of the block GUID.

Parameters:
fhash - the secure hash at the root of the verification tree

computeVhash

public SecureHash computeVhash()
Compute and return the verification hash of the object.

Returns:
the vhash of the object

toVhashBytes

public void toVhashBytes(byte[] data,
                         int[] offset)
Serialize the object in a form suitable for computing the verification hash of the object. The parameters and their meaning mimic those of the QuickSerializable.to_bytes() method. @see ostore.util.QuickSerializable#to_bytes

Parameters:
data - See ostore.util.QuickSerializable.to_bytes
offset - See ostore.util.QuickSerializable.to_bytes

verifyVhash

public boolean verifyVhash(SecureHash vhash)
Verify the contents of the object against its given verification hash. This method will compute the verification hash of the object and compare that hash against the alleged hash of the object to determine its validity.

Parameters:
vhash - the vhash against which to verify the object
Returns:
true iff the hash of the object matches vhash; false otherwise

computeGuid

public SecureHash computeGuid()
                       throws BlockNotGuidVerifiableException
Compute and return the guid of the object. As a precondition, the secure hash of the root of the fragment verification tree must be set.

Returns:
the guid of the object
Throws:
ostore.util.BlockNotGuidVerifiable - if the precondition is not satisfied.
BlockNotGuidVerifiableException
See Also:
setFhash(ostore.util.SecureHash)

toGuidBytes

public void toGuidBytes(byte[] data,
                        int[] offset)
                 throws BlockNotGuidVerifiableException
Serialize the object in a form suitable for computing the block guid of the object. The parameters and their meaning mimic those of the QuickSerializable.to_bytes() method. @see ostore.util.QuickSerializable#to_bytes As a precondition, the secure hash of the root of the fragment verification tree must be set.

Parameters:
data - See ostore.util.QuickSerializable.to_bytes
offset - See ostore.util.QuickSerializable.to_bytes
Throws:
ostore.util.BlockNotGuidVerifiable - if the precondition is not satisfied.
BlockNotGuidVerifiableException

verifyGuid

public boolean verifyGuid(SecureHash bguid)
                   throws BlockNotGuidVerifiableException
Verify the contents of the object against its given guid. This method will compute the guid of the object and compare that hash against the alleged name of the object to determine its validity. As a precondition, the secure hash of the root of the fragment verification tree must be set.

Parameters:
bguid - the block guid against which to verify the object
Returns:
true iff the guid of the object matches bguid; false otherwise
Throws:
ostore.util.BlockNotGuidVerifiable - if the precondition is not satisfied.
BlockNotGuidVerifiableException