diff --git a/libs/apkverify/Android.bp b/libs/apkverify/Android.bp index 18628200..e5568427 100644 --- a/libs/apkverify/Android.bp +++ b/libs/apkverify/Android.bp @@ -12,6 +12,7 @@ rust_defaults { "libanyhow", "libbyteorder", "libbytes", + "libhex", "liblog_rust", "libnum_traits", "libopenssl", @@ -33,7 +34,6 @@ rust_test { name: "libapkverify.test", defaults: ["libapkverify.defaults"], test_suites: ["general-tests"], - rustlibs: ["libhex"], data: ["tests/data/*"], } diff --git a/libs/apkverify/src/sigutil.rs b/libs/apkverify/src/sigutil.rs index bfa51c1c..395b4934 100644 --- a/libs/apkverify/src/sigutil.rs +++ b/libs/apkverify/src/sigutil.rs @@ -235,7 +235,7 @@ mod tests { use std::fs::File; use std::mem::size_of_val; - use crate::v3::{to_hex_string, APK_SIGNATURE_SCHEME_V3_BLOCK_ID}; + use crate::v3::APK_SIGNATURE_SCHEME_V3_BLOCK_ID; const CENTRAL_DIRECTORY_HEADER_SIGNATURE: u32 = 0x02014b50; @@ -276,8 +276,8 @@ mod tests { let mut apk_sections = ApkSections::new(apk_file).unwrap(); let digest = apk_sections.compute_digest(SignatureAlgorithmID::DsaWithSha256).unwrap(); assert_eq!( - "0DF2426EA33AEDAF495D88E5BE0C6A1663FF0A81C5ED12D5B2929AE4B4300F2F", - to_hex_string(&digest[..]) + "0df2426ea33aedaf495d88e5be0c6a1663ff0a81c5ed12d5b2929ae4b4300f2f", + hex::encode(&digest[..]) ); } diff --git a/libs/apkverify/src/v3.rs b/libs/apkverify/src/v3.rs index db7d8ccf..fcd966b8 100644 --- a/libs/apkverify/src/v3.rs +++ b/libs/apkverify/src/v3.rs @@ -196,8 +196,8 @@ impl Signer { ensure!( computed == digest.digest.as_ref(), "Digest mismatch: computed={:?} vs expected={:?}", - to_hex_string(&computed), - to_hex_string(&digest.digest), + hex::encode(&computed), + hex::encode(digest.digest.as_ref()), ); // 7. Verify that public key of the first certificate of certificates is identical @@ -261,8 +261,3 @@ impl ReadFromBytes for PKey { Ok(PKey::public_key_from_der(raw_public_key.as_ref())?) } } - -#[inline] -pub(crate) fn to_hex_string(buf: &[u8]) -> String { - buf.iter().map(|b| format!("{:02X}", b)).collect() -}