From 8502937cff58c036a2ac05671e1e46d1cbb46425 Mon Sep 17 00:00:00 2001 From: Alex Klyubin Date: Tue, 12 Jan 2016 12:23:11 -0800 Subject: [PATCH] List SHA-1 digests of APK entries' contents in .SF files. Due to a bug introduced in 8562fd478d7f1b1b693de5db67928f1993522c0a SHA-1 digests of APK entries' contents were listed under wrong attribute name. The effect is equivalent to not listing SHA-1 digests. This change fix the issue by listing SHA-1 digests under the correct attribute name. However, these digests are not that useful because: (1) typically the digest of the MANIFEST.MF verifies and thus the per-entry digests are ignored, and (2) per-entry digests of entries with names longer than 64 characters are wrong in any case because the digest generation code does not take into account that such names are split over multiple lines. An alternative to this change would be to completely omit outputting per-entry sections of .SF files, thus saving space and speeding up APK verification (.SF files would decompress faster). Bug: 26513901 Change-Id: If95d58e9baa62b1113639fe70724e1e9c9f4e15c --- tools/signapk/src/com/android/signapk/SignApk.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/signapk/src/com/android/signapk/SignApk.java b/tools/signapk/src/com/android/signapk/SignApk.java index 5afb8d106..dd02b096d 100644 --- a/tools/signapk/src/com/android/signapk/SignApk.java +++ b/tools/signapk/src/com/android/signapk/SignApk.java @@ -418,7 +418,7 @@ class SignApk { print.flush(); Attributes sfAttr = new Attributes(); - sfAttr.putValue(hash == USE_SHA256 ? "SHA-256-Digest" : "SHA1-Digest-Manifest", + sfAttr.putValue(hash == USE_SHA256 ? "SHA-256-Digest" : "SHA1-Digest", new String(Base64.encode(md.digest()), "ASCII")); sf.getEntries().put(entry.getKey(), sfAttr); }