OSDN Git Service

List SHA-1 digests of APK entries' contents in .SF files.
authorAlex Klyubin <klyubin@google.com>
Tue, 12 Jan 2016 20:23:11 +0000 (12:23 -0800)
committerAlex Klyubin <klyubin@google.com>
Tue, 12 Jan 2016 20:36:46 +0000 (12:36 -0800)
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

index 5afb8d1..dd02b09 100644 (file)
@@ -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);
         }