idsig: make it as an Android module

Bug: 193504400
Test: m libidsig libidsig.test
Change-Id: Id42919fb46a6b4dff7ef9e5af1c2a95635ce85ab
diff --git a/idsig/Android.bp b/idsig/Android.bp
new file mode 100644
index 0000000..647915b
--- /dev/null
+++ b/idsig/Android.bp
@@ -0,0 +1,33 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+rust_defaults {
+    name: "libidsig.defaults",
+    crate_name: "idsig",
+    srcs: ["src/lib.rs"],
+    edition: "2018",
+    prefer_rlib: true,
+    rustlibs: [
+        "libanyhow",
+        "libring",
+    ],
+    proc_macros: ["libnum_derive"],
+    multilib: {
+        lib32: {
+            enabled: false,
+        },
+    },
+}
+
+rust_library {
+    name: "libidsig",
+    defaults: ["libidsig.defaults"],
+}
+
+rust_test {
+    name: "libidsig.test",
+    defaults: ["libidsig.defaults"],
+    test_suites: ["general-tests"],
+    compile_multilib: "first",
+}
diff --git a/idsig/src/lib.rs b/idsig/src/lib.rs
index 547fa47..97c6024 100644
--- a/idsig/src/lib.rs
+++ b/idsig/src/lib.rs
@@ -13,12 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//! `idsig` provides routines for creating the idsig file that is defined for the APK signature
+//! scheme v4 and for parsing the file.
+
 use ring::digest::{self, Algorithm};
 use std::io::{Cursor, Read, Result, Seek, SeekFrom, Write};
 
 /// `HashTree` is a merkle tree (and its root hash) that is compatible with fs-verity.
 pub struct HashTree {
+    /// Binary presentation of the merkle tree
     pub tree: Vec<u8>,
+    /// Root hash
     pub root_hash: Vec<u8>,
 }
 
@@ -32,7 +38,7 @@
         block_size: usize,
         algorithm: &'static Algorithm,
     ) -> Result<Self> {
-        let salt = zero_pad_salt(&salt, algorithm);
+        let salt = zero_pad_salt(salt, algorithm);
         let tree = generate_hash_tree(input, input_size, &salt, block_size, algorithm)?;
 
         // Root hash is from the first block of the hash or the input data if there is no hash tree