From ad4e1904e1c3d18cbd84538b9be94d8d4a216f0e Mon Sep 17 00:00:00 2001 From: Jakob Cornell Date: Mon, 21 Feb 2022 13:14:15 -0600 Subject: [PATCH] Fix bugs in verify v2 and in verify v1 slab construction --- disk_jumble/src/disk_jumble/db.py | 5 +++-- disk_jumble/src/disk_jumble/verify.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/disk_jumble/src/disk_jumble/db.py b/disk_jumble/src/disk_jumble/db.py index 5b7e2f8..66e7562 100644 --- a/disk_jumble/src/disk_jumble/db.py +++ b/disk_jumble/src/disk_jumble/db.py @@ -14,7 +14,7 @@ class Slab: sectors: range entity_id: bytes entity_offset: int - crypt_key: bytes + crypt_key: Optional[bytes] @dataclass @@ -114,8 +114,9 @@ class Wrapper: cursor.execute(stmt, {"disk_id": disk_id, "sector_size": sector_size}) for (_, rows_iter) in itertools.groupby(cursor, lambda r: r[0]): rows = list(rows_iter) - [(slab_id, disk_id, sectors_pg, entity_id, entity_off, key)] = {r[:6] for r in rows} + [(slab_id, disk_id, sectors_pg, entity_id, entity_off, key_mem)] = {r[:6] for r in rows} sectors = range(sectors_pg.lower, sectors_pg.upper) + key = None if key_mem is None else bytes(key_mem) slab = Slab(slab_id, disk_id, sectors, bytes(entity_id), entity_off, key) # `None' if no hasher match in outer join, otherwise earliest match diff --git a/disk_jumble/src/disk_jumble/verify.py b/disk_jumble/src/disk_jumble/verify.py index 9466270..684739d 100644 --- a/disk_jumble/src/disk_jumble/verify.py +++ b/disk_jumble/src/disk_jumble/verify.py @@ -266,7 +266,7 @@ def _gen_verify_results(conn, disk_id: int, disk_file: io.BufferedIOBase, read_s - 1 ) ) as sector, - entity.length as entity_length + entity.length as entity_length, substring(hashes, generate_series(0, octet_length(hashes) / 32 - 1, 32), 32) as hash, crypt_key from ( -- 2.30.2