]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
disable plaintext hashes in shares, but leave a switch to turn it back on
authorBrian Warner <warner@allmydata.com>
Mon, 24 Mar 2008 20:39:51 +0000 (13:39 -0700)
committerBrian Warner <warner@allmydata.com>
Mon, 24 Mar 2008 20:39:51 +0000 (13:39 -0700)
src/allmydata/encode.py
src/allmydata/test/test_encode.py
src/allmydata/test/test_system.py

index a815a5d7795b406ecd57e26a8f116f12eb0c9fe1..2a95cabbf80a80b3691e3daffa9cdfc7cd12aea3 100644 (file)
@@ -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():
index 67b7e15b43e6645316c2ed95217f1c72953f6eff..cf2ab20bc50cf779e353917aa4ab4bb9f0a3d78f 100644 (file)
@@ -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,
index 3fa9441e1ec64ce200cc5b5a68886bb78a8cb577..6800bab5239f1b04ae5ea9aa1b0deda9b336c204 100644 (file)
@@ -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)