Commit 8b0b4a2c authored by osm0sis's avatar osm0sis Committed by John Wu

SignBoot: also catch empty streamed signature as indicating not signed

- compare against new byte[] array as a quick tell, since when streaming from a partition with an unsigned image "signature" would of course read without issue but then remain filled by zero padding, resulting in the following:
    java.io.IOException: unexpected end-of-contents marker
        at org.bouncycastle.asn1.ASN1InputStream.readObject(Unknown Source:14)
        at com.topjohnwu.signing.SignBoot$BootSignature.<init>(SignBoot.java:235)
        at com.topjohnwu.signing.SignBoot.verifySignature(SignBoot.java:144)
        at com.topjohnwu.signing.BootSigner.main(BootSigner.java:15)
        at a.a.main(a.java:20)
parent c0216c06
...@@ -136,7 +136,7 @@ public class SignBoot { ...@@ -136,7 +136,7 @@ public class SignBoot {
// Read footer, which contains the signature // Read footer, which contains the signature
byte[] signature = new byte[4096]; byte[] signature = new byte[4096];
if (imgIn.read(signature) == -1) { if (imgIn.read(signature) == -1 || Arrays.equals(signature, new byte [signature.length])) {
System.err.println("Invalid image: not signed"); System.err.println("Invalid image: not signed");
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment