Fix idsig for a large APK files

Bug: 210800944
Test: atest --test-mapping idsig
Change-Id: I74c42e384fadfb8363306a3ead91869d15f4f0da
diff --git a/idsig/src/hashtree.rs b/idsig/src/hashtree.rs
index 1ce2879..63f83ea 100644
--- a/idsig/src/hashtree.rs
+++ b/idsig/src/hashtree.rs
@@ -100,7 +100,7 @@
             // and split it.
             let prev = &levels[n - 1];
             let cur_and_prev = &mut hash_tree[cur.start..prev.end];
-            let (cur, prev) = cur_and_prev.split_at_mut(prev.start);
+            let (cur, prev) = cur_and_prev.split_at_mut(prev.start - cur.start);
             let mut cur = Cursor::new(cur);
             prev.chunks(block_size).for_each(|data| {
                 let h = hash_one_block(data, salt, block_size, algorithm);
@@ -200,7 +200,7 @@
     #[test]
     fn compare_with_golden_output() -> Result<()> {
         // The golden outputs are generated by using the `fsverity` utility.
-        let sizes = ["512", "4K", "1M", "10000000"];
+        let sizes = ["512", "4K", "1M", "10000000", "272629760"];
         for size in sizes.iter() {
             let input_name = format!("testdata/input.{}", size);
             let mut input = File::open(&input_name)?;
diff --git a/idsig/testdata/create.sh b/idsig/testdata/create.sh
index eadfdb2..1a15d2b 100755
--- a/idsig/testdata/create.sh
+++ b/idsig/testdata/create.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-sizes="512 4K 1M 10000000"
+sizes="512 4K 1M 10000000 272629760"
 for size in $sizes; do
   echo $size
   dd if=/dev/random of=input.$size bs=$size count=1
diff --git a/idsig/testdata/input.272629760 b/idsig/testdata/input.272629760
new file mode 100644
index 0000000..5bb6753
--- /dev/null
+++ b/idsig/testdata/input.272629760
Binary files differ
diff --git a/idsig/testdata/input.272629760.descriptor b/idsig/testdata/input.272629760.descriptor
new file mode 100644
index 0000000..70e0744
--- /dev/null
+++ b/idsig/testdata/input.272629760.descriptor
Binary files differ
diff --git a/idsig/testdata/input.272629760.hash b/idsig/testdata/input.272629760.hash
new file mode 100644
index 0000000..f2c68cc
--- /dev/null
+++ b/idsig/testdata/input.272629760.hash
Binary files differ