]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
rename storage_index_chk_hash() to storage_index_hash() and add TODO about how our...
authorZooko O'Whielacronx <zooko@zooko.com>
Fri, 1 Feb 2008 19:27:37 +0000 (12:27 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Fri, 1 Feb 2008 19:27:37 +0000 (12:27 -0700)
src/allmydata/test/test_cli.py
src/allmydata/test/test_helper.py
src/allmydata/test/test_uri.py
src/allmydata/upload.py
src/allmydata/uri.py
src/allmydata/util/hashutil.py

index bb1d704bc6f3d7da42671f3dcbf87ef59dcb07c1..7d941985b2061a351ae291a3cdb68286ed796555 100644 (file)
@@ -77,7 +77,7 @@ class CLI(unittest.TestCase):
 
     def test_dump_cap_chk(self):
         key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
-        storage_index = hashutil.storage_index_chk_hash(key)
+        storage_index = hashutil.storage_index_hash(key)
         uri_extension_hash = hashutil.uri_extension_hash("stuff")
         needed_shares = 25
         total_shares = 100
index 6fa96585d347e2b121abfea0966a69031b6de4a3..8599512463ae4a051592217107a0ed038e538804 100644 (file)
@@ -124,7 +124,7 @@ class AssistedUpload(unittest.TestCase):
         # populating the directory manually.
         key = hashutil.key_hash(DATA)[:16]
         encryptor = AES(key)
-        SI = hashutil.storage_index_chk_hash(key)
+        SI = hashutil.storage_index_hash(key)
         SI_s = idlib.b2a(SI)
         encfile = os.path.join(self.basedir, "CHK_encoding", SI_s)
         f = open(encfile, "wb")
index 6b3cee0ced0f41259d9295c15d7fa1e596fa24d1..7ccd32785e1744b7a31310b28a1e98e9e8633730 100644 (file)
@@ -57,7 +57,7 @@ class Compare(unittest.TestCase):
 class CHKFile(unittest.TestCase):
     def test_pack(self):
         key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
-        storage_index = hashutil.storage_index_chk_hash(key)
+        storage_index = hashutil.storage_index_hash(key)
         uri_extension_hash = hashutil.uri_extension_hash("stuff")
         needed_shares = 25
         total_shares = 100
@@ -116,7 +116,7 @@ class CHKFile(unittest.TestCase):
 
     def test_pack_badly(self):
         key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
-        storage_index = hashutil.storage_index_chk_hash(key)
+        storage_index = hashutil.storage_index_hash(key)
         uri_extension_hash = hashutil.uri_extension_hash("stuff")
         needed_shares = 25
         total_shares = 100
index 7a9d0b347ca821b084ac2dd45968b9b509ee7946..ed147f1604f7182fcbb3867c7b062f3c560ddbae 100644 (file)
@@ -11,7 +11,7 @@ from foolscap.logging import log
 from allmydata.util.hashutil import file_renewal_secret_hash, \
      file_cancel_secret_hash, bucket_renewal_secret_hash, \
      bucket_cancel_secret_hash, plaintext_hasher, \
-     storage_index_chk_hash, plaintext_segment_hasher, key_hasher
+     storage_index_hash, plaintext_segment_hasher, key_hasher
 from allmydata import encode, storage, hashtree, uri
 from allmydata.util import idlib, mathutil
 from allmydata.util.assertutil import precondition
@@ -404,7 +404,7 @@ class EncryptAnUploadable:
             e = AES(key)
             self._encryptor = e
 
-            storage_index = storage_index_chk_hash(key)
+            storage_index = storage_index_hash(key)
             assert isinstance(storage_index, str)
             # There's no point to having the SI be longer than the key, so we
             # specify that it is truncated to the same 128 bits as the AES key.
index 51ebec878f0a7365beacb290f91de8a28c2906ce..44df1f483a5bf83cbfdebdc6ad651bfb91d0dcb7 100644 (file)
@@ -50,9 +50,9 @@ class CHKFileURI(_BaseURI):
         self.needed_shares = needed_shares
         self.total_shares = total_shares
         self.size = size
-        self.storage_index = hashutil.storage_index_chk_hash(self.key)
+        self.storage_index = hashutil.storage_index_hash(self.key)
         assert len(self.storage_index) == 16
-        self.storage_index = hashutil.storage_index_chk_hash(key)
+        self.storage_index = hashutil.storage_index_hash(key)
         assert len(self.storage_index) == 16 # sha256 hash truncated to 128
 
     @classmethod
index 218be2ed97411df99f6686cd87c26cb8e2e98612..1dfcb2a41d0cd93798bb575ae127ce0555b4cad0 100644 (file)
@@ -32,10 +32,15 @@ def tagged_pair_hash(tag, val1, val2):
 def tagged_hasher(tag):
     return SHA256(netstring(tag))
 
-def storage_index_chk_hash(data):
+def storage_index_hash(key):
     # storage index is truncated to 128 bits (16 bytes). We're only hashing a
     # 16-byte value to get it, so there's no point in using a larger value.
-    return tagged_hash("allmydata_CHK_storage_index_v1", data)[:16]
+    # TODO: remove the word "CHK" from this tag since we use this same tagged
+    # hash for random-keyed immutable files, mutable files, content-hash-keyed
+    # immutabie files.  Or, define two other tagged hashes, one for each kind.
+    # (Either way is fine -- we can never have collisions of storage indexes
+    # anyway, since we can't have collisions of keys.)
+    return tagged_hash("allmydata_CHK_storage_index_v1", key)[:16]
 
 def block_hash(data):
     return tagged_hash("allmydata_encoded_subshare_v1", data)