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
# 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")
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
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
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
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.
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
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)