Don't try to verify encrypted data
authorJakob Cornell <jakob+gpg@jcornell.net>
Mon, 21 Feb 2022 19:12:09 +0000 (13:12 -0600)
committerJakob Cornell <jakob+gpg@jcornell.net>
Mon, 21 Feb 2022 20:29:57 +0000 (14:29 -0600)
disk_jumble/src/disk_jumble/verify.py

index 6c15143390fb4b0bd27d395dd0d6950e4c0f7f8c..946627015f117783742ec43dce77c28821d0b0f7 100644 (file)
@@ -66,8 +66,10 @@ def do_verify(conn, disk_id: int, sector_size: int, disk_file: io.BufferedIOBase
                use_hasher = None
                chunks = []
                for (slab, hasher_ref) in group:
-                       slab_end = min(slab.entity_offset + len(slab.sectors) * sector_size, torrent_len)
+                       if slab.crypt_key is not None:
+                               raise NotImplementedError("verify of encrypted data")
 
+                       slab_end = min(slab.entity_offset + len(slab.sectors) * sector_size, torrent_len)
                        while offset is None or offset < slab_end:
                                if offset is not None and slab.entity_offset > offset:
                                        if chunks:
@@ -265,7 +267,8 @@ def _gen_verify_results(conn, disk_id: int, disk_file: io.BufferedIOBase, read_s
                                                )
                                        ) as sector,
                                        entity.length as entity_length
-                                       substring(hashes, generate_series(0, octet_length(hashes) / 32 - 1, 32), 32) as hash
+                                       substring(hashes, generate_series(0, octet_length(hashes) / 32 - 1, 32), 32) as hash,
+                                       crypt_key
                                from (
                                        entityv2_leaf_hashes elh
                                        join slab_plus on (
@@ -279,7 +282,10 @@ def _gen_verify_results(conn, disk_id: int, disk_file: io.BufferedIOBase, read_s
                        """,
                        {"block_size": _V2_BLOCK_SIZE, "disk_id": disk_id}
                )
-               for (entity_id, piece_num, sector, entity_len, hash_) in cursor:
+               for (entity_id, piece_num, sector, entity_len, hash_, crypt_key) in cursor:
+                       if crypt_key is not None:
+                               raise NotImplementedError("verify of encrypted data")
+
                        read_start = sector * _V2_BLOCK_SIZE
                        read_end = read_start + min(_V2_BLOCK_SIZE, entity_len - piece_num * _V2_BLOCK_SIZE)
                        disk_file.seek(read_start)