BootSigner: add ability to change target name

- supports signing /recovery images
- add as final argument and default to /boot if not supplied so installer scripts remain the same
This commit is contained in:
osm0sis 2019-07-04 03:17:14 -03:00 committed by John Wu
parent 4f4a9412a3
commit aaf88b1895

View File

@ -18,13 +18,17 @@ public class BootSigner {
} else if (args.length > 0 && "-sign".equals(args[0])) { } else if (args.length > 0 && "-sign".equals(args[0])) {
InputStream cert = null; InputStream cert = null;
InputStream key = null; InputStream key = null;
String name = "/boot";
if (args.length >= 3) { if (args.length >= 3) {
cert = new FileInputStream(args[1]); cert = new FileInputStream(args[1]);
key = new FileInputStream(args[2]); key = new FileInputStream(args[2]);
} }
if (args.length >= 4) {
name = args[3];
}
boolean success = SignBoot.doSignature("/boot", System.in, System.out, cert, key); boolean success = SignBoot.doSignature(name, System.in, System.out, cert, key);
System.exit(success ? 0 : 1); System.exit(success ? 0 : 1);
} else { } else {
System.err.println( System.err.println(
@ -34,8 +38,9 @@ public class BootSigner {
"Actions:\n" + "Actions:\n" +
" -verify [x509.pem]\n" + " -verify [x509.pem]\n" +
" verify image, cert is optional\n" + " verify image, cert is optional\n" +
" -sign [x509.pem] [pk8]\n" + " -sign [x509.pem] [pk8] [name]\n" +
" sign image, cert and key pair is optional\n" " sign image, name, cert and key pair are optional\n" +
" name should be /boot (default) or /recovery\n"
); );
} }
} }