dump-cap: include UEB_hash in output

This commit is contained in:
Brian Warner 2008-02-06 12:48:19 -07:00
parent 40c2371e77
commit e92a2b5ab2
3 changed files with 6 additions and 5 deletions

View File

@ -34,15 +34,15 @@ def dump_share(config, out=sys.stdout, err=sys.stderr):
seek = offsets['uri_extension'] seek = offsets['uri_extension']
length = struct.unpack(">L", f.read_share_data(seek, 4))[0] length = struct.unpack(">L", f.read_share_data(seek, 4))[0]
seek += 4 seek += 4
data = f.read_share_data(seek, length) UEB_data = f.read_share_data(seek, length)
unpacked = uri.unpack_extension_readable(data) unpacked = uri.unpack_extension_readable(UEB_data)
keys1 = ("size", "num_segments", "segment_size", keys1 = ("size", "num_segments", "segment_size",
"needed_shares", "total_shares") "needed_shares", "total_shares")
keys2 = ("codec_name", "codec_params", "tail_codec_params") keys2 = ("codec_name", "codec_params", "tail_codec_params")
keys3 = ("plaintext_hash", "plaintext_root_hash", keys3 = ("plaintext_hash", "plaintext_root_hash",
"crypttext_hash", "crypttext_root_hash", "crypttext_hash", "crypttext_root_hash",
"share_root_hash") "share_root_hash", "UEB_hash")
display_keys = {"size": "file_size"} display_keys = {"size": "file_size"}
for k in keys1: for k in keys1:
if k in unpacked: if k in unpacked:
@ -70,7 +70,7 @@ def dump_share(config, out=sys.stdout, err=sys.stderr):
sizes['data'] = bp._data_size sizes['data'] = bp._data_size
sizes['validation'] = (offsets['uri_extension'] - sizes['validation'] = (offsets['uri_extension'] -
offsets['plaintext_hash_tree']) offsets['plaintext_hash_tree'])
sizes['uri-extension'] = len(data) sizes['uri-extension'] = len(UEB_data)
print >>out print >>out
print >>out, "Size of data within the share:" print >>out, "Size of data within the share:"
for k in sorted(sizes): for k in sorted(sizes):

View File

@ -1155,7 +1155,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, unittest.TestCase):
"codec_name", "codec_params", "tail_codec_params", "codec_name", "codec_params", "tail_codec_params",
"plaintext_hash", "plaintext_root_hash", "plaintext_hash", "plaintext_root_hash",
"crypttext_hash", "crypttext_root_hash", "crypttext_hash", "crypttext_root_hash",
"share_root_hash",): "share_root_hash", "UEB_hash"):
self.failUnless("%s: " % key in output, key) self.failUnless("%s: " % key in output, key)
def _test_control(self, res): def _test_control(self, res):

View File

@ -508,6 +508,7 @@ def unpack_extension(data):
def unpack_extension_readable(data): def unpack_extension_readable(data):
unpacked = unpack_extension(data) unpacked = unpack_extension(data)
unpacked["UEB_hash"] = hashutil.uri_extension_hash(data)
for k in sorted(unpacked.keys()): for k in sorted(unpacked.keys()):
if 'hash' in k: if 'hash' in k:
unpacked[k] = idlib.b2a(unpacked[k]) unpacked[k] = idlib.b2a(unpacked[k])