mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 13:33:09 +00:00
disable plaintext hashes in shares, but leave a switch to turn it back on
This commit is contained in:
parent
7b21054c33
commit
1e097766c9
@ -74,6 +74,7 @@ PiB=1024*TiB
|
||||
|
||||
class Encoder(object):
|
||||
implements(IEncoder)
|
||||
USE_PLAINTEXT_HASHES = False
|
||||
|
||||
def __init__(self, log_parent=None, upload_status=None):
|
||||
object.__init__(self)
|
||||
@ -239,8 +240,9 @@ class Encoder(object):
|
||||
|
||||
d.addCallback(lambda res: self.finish_hashing())
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.send_plaintext_hash_tree_to_all_shareholders())
|
||||
if self.USE_PLAINTEXT_HASHES:
|
||||
d.addCallback(lambda res:
|
||||
self.send_plaintext_hash_tree_to_all_shareholders())
|
||||
d.addCallback(lambda res:
|
||||
self.send_crypttext_hash_tree_to_all_shareholders())
|
||||
d.addCallback(lambda res: self.send_all_subshare_hash_trees())
|
||||
@ -512,19 +514,21 @@ class Encoder(object):
|
||||
self.set_encode_and_push_progress(extra=0.0)
|
||||
crypttext_hash = self._crypttext_hasher.digest()
|
||||
self.uri_extension_data["crypttext_hash"] = crypttext_hash
|
||||
d = self._uploadable.get_plaintext_hash()
|
||||
def _got(plaintext_hash):
|
||||
self.uri_extension_data["plaintext_hash"] = plaintext_hash
|
||||
return self._uploadable.get_plaintext_hashtree_leaves(0, self.num_segments, self.num_segments)
|
||||
d.addCallback(_got)
|
||||
def _got_hashtree_leaves(leaves):
|
||||
self.log("Encoder: got plaintext_hashtree_leaves: %s" %
|
||||
(",".join([base32.b2a(h) for h in leaves]),),
|
||||
level=log.NOISY)
|
||||
ht = list(HashTree(list(leaves)))
|
||||
self.uri_extension_data["plaintext_root_hash"] = ht[0]
|
||||
self._plaintext_hashtree_nodes = ht
|
||||
d.addCallback(_got_hashtree_leaves)
|
||||
d = defer.succeed(None)
|
||||
if self.USE_PLAINTEXT_HASHES:
|
||||
d.addCallback(lambda res: self._uploadable.get_plaintext_hash())
|
||||
def _got(plaintext_hash):
|
||||
self.uri_extension_data["plaintext_hash"] = plaintext_hash
|
||||
return self._uploadable.get_plaintext_hashtree_leaves(0, self.num_segments, self.num_segments)
|
||||
d.addCallback(_got)
|
||||
def _got_hashtree_leaves(leaves):
|
||||
self.log("Encoder: got plaintext_hashtree_leaves: %s" %
|
||||
(",".join([base32.b2a(h) for h in leaves]),),
|
||||
level=log.NOISY)
|
||||
ht = list(HashTree(list(leaves)))
|
||||
self.uri_extension_data["plaintext_root_hash"] = ht[0]
|
||||
self._plaintext_hashtree_nodes = ht
|
||||
d.addCallback(_got_hashtree_leaves)
|
||||
|
||||
d.addCallback(lambda res: self._uploadable.close())
|
||||
return d
|
||||
@ -630,9 +634,12 @@ class Encoder(object):
|
||||
self.set_status("Sending URI Extensions")
|
||||
self.set_encode_and_push_progress(extra=0.8)
|
||||
for k in ('crypttext_root_hash', 'crypttext_hash',
|
||||
'plaintext_root_hash', 'plaintext_hash',
|
||||
):
|
||||
assert k in self.uri_extension_data
|
||||
if self.USE_PLAINTEXT_HASHES:
|
||||
for k in ('plaintext_root_hash', 'plaintext_hash',
|
||||
):
|
||||
assert k in self.uri_extension_data
|
||||
uri_extension = uri.pack_extension(self.uri_extension_data)
|
||||
ed = {}
|
||||
for k,v in self.uri_extension_data.items():
|
||||
|
@ -521,7 +521,7 @@ class Roundtrip(unittest.TestCase):
|
||||
d.addCallback(self.assertFetchFailureIn, "uri_extension")
|
||||
return d
|
||||
|
||||
def test_bad_plaintext_hashroot(self):
|
||||
def OFF_test_bad_plaintext_hashroot(self):
|
||||
# the first server has a bad plaintext hashroot, so we will fail over
|
||||
# to a different server.
|
||||
modemap = dict([(i, "bad plaintext hashroot") for i in range(1)] +
|
||||
@ -539,7 +539,7 @@ class Roundtrip(unittest.TestCase):
|
||||
d.addCallback(self.assertFetchFailureIn, "crypttext_hashroot")
|
||||
return d
|
||||
|
||||
def test_bad_plaintext_hashes(self):
|
||||
def OFF_test_bad_plaintext_hashes(self):
|
||||
# the first server has a bad plaintext hash block, so we will fail
|
||||
# over to a different server.
|
||||
modemap = dict([(i, "bad plaintext hash") for i in range(1)] +
|
||||
@ -576,7 +576,7 @@ class Roundtrip(unittest.TestCase):
|
||||
return d
|
||||
|
||||
|
||||
def test_bad_plaintext(self):
|
||||
def OFF_test_bad_plaintext(self):
|
||||
# faking a decryption failure is easier: just corrupt the key
|
||||
modemap = dict([(i, "good") for i in range(0, 10)])
|
||||
d = self.send_and_recover((4,8,10), bucket_modes=modemap,
|
||||
|
@ -1303,7 +1303,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, unittest.TestCase):
|
||||
for key in ("size", "num_segments", "segment_size",
|
||||
"needed_shares", "total_shares",
|
||||
"codec_name", "codec_params", "tail_codec_params",
|
||||
"plaintext_hash", "plaintext_root_hash",
|
||||
#"plaintext_hash", "plaintext_root_hash",
|
||||
"crypttext_hash", "crypttext_root_hash",
|
||||
"share_root_hash", "UEB_hash"):
|
||||
self.failUnless("%s: " % key in output, key)
|
||||
|
Loading…
Reference in New Issue
Block a user