class Encoder(object):
implements(IEncoder)
+ USE_PLAINTEXT_HASHES = False
def __init__(self, log_parent=None, upload_status=None):
object.__init__(self)
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())
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
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():
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)] +
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)] +
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,
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)