diff --git a/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java b/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java index a97b47e6e..7068ef72f 100644 --- a/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java +++ b/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java @@ -205,11 +205,9 @@ public class InstallMagisk extends ParallelTask { AssetManager assets = mm.getAssets(); try ( InputStream in = new FileInputStream(patched_boot); - OutputStream out = new BufferedOutputStream(new FileOutputStream(signed)); - InputStream keyIn = assets.open(Const.PRIVATE_KEY_NAME); - InputStream certIn = assets.open(Const.PUBLIC_KEY_NAME) + OutputStream out = new BufferedOutputStream(new FileOutputStream(signed)) ) { - SignBoot.doSignature("/boot", in, out, keyIn, certIn); + SignBoot.doSignature("/boot", in, out, null, null); } shell.run(null, null, "mv -f " + signed + " " + patched_boot); } diff --git a/src/main/java/com/topjohnwu/magisk/utils/BootSigner.java b/src/main/java/com/topjohnwu/magisk/utils/BootSigner.java index 57df26cab..a6ee3ed3d 100644 --- a/src/main/java/com/topjohnwu/magisk/utils/BootSigner.java +++ b/src/main/java/com/topjohnwu/magisk/utils/BootSigner.java @@ -6,8 +6,6 @@ import com.topjohnwu.crypto.SignBoot; import java.io.FileInputStream; import java.io.InputStream; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; public class BootSigner { @@ -15,30 +13,23 @@ public class BootSigner { public static void main(String[] args) throws Exception { if (args.length > 0 && "-verify".equals(args[0])) { String certPath = ""; - if (args.length >= 3 && "-certificate".equals(args[1])) { - /* args[2] is the path to a public key certificate */ - certPath = args[2]; + if (args.length >= 2) { + /* args[1] is the path to a public key certificate */ + certPath = args[1]; } - /* args[1] is the path to a signed boot image */ boolean signed = SignBoot.verifySignature(System.in, certPath.isEmpty() ? null : new FileInputStream(certPath)); System.exit(signed ? 0 : 1); } else if (args.length > 0 && "-sign".equals(args[0])) { - InputStream keyIn, certIn; - if (args.length >= 3) { - keyIn = new FileInputStream(args[1]); - certIn = new FileInputStream(args[2]); - } else { - /* Use internal test keys */ - JarFile apk = new JarFile(System.getProperty("java.class.path")); - JarEntry keyEntry = apk.getJarEntry("assets/" + Const.PRIVATE_KEY_NAME); - JarEntry sigEntry = apk.getJarEntry("assets/" + Const.PUBLIC_KEY_NAME); + InputStream cert = null; + InputStream key = null; - keyIn = apk.getInputStream(keyEntry); - certIn = apk.getInputStream(sigEntry); + if (args.length >= 3) { + cert = new FileInputStream(args[1]); + key = new FileInputStream(args[2]); } - boolean success = SignBoot.doSignature("/boot", System.in, System.out, keyIn, certIn); + boolean success = SignBoot.doSignature("/boot", System.in, System.out, cert, key); System.exit(success ? 0 : 1); } else { System.err.println( @@ -48,8 +39,8 @@ public class BootSigner { "Actions:\n" + " -verify [x509.pem]\n" + " verify image, cert is optional\n" + - " -sign [pk8] [x509.pem]\n" + - " sign image, key and cert are optional\n" + " -sign [x509.pem] [pk8]\n" + + " sign image, cert and key pair is optional\n" ); } } diff --git a/src/main/java/com/topjohnwu/magisk/utils/Const.java b/src/main/java/com/topjohnwu/magisk/utils/Const.java index bc46057df..986747f2b 100644 --- a/src/main/java/com/topjohnwu/magisk/utils/Const.java +++ b/src/main/java/com/topjohnwu/magisk/utils/Const.java @@ -17,8 +17,6 @@ public class Const { public static final String MAGISKHIDE_PROP = "persist.magisk.hide"; // APK content - public static final String PUBLIC_KEY_NAME = "public.certificate.x509.pem"; - public static final String PRIVATE_KEY_NAME = "private.key.pk8"; public static final String UNINSTALLER = "magisk_uninstaller.sh"; public static final String UTIL_FUNCTIONS= "util_functions.sh"; public static final String ANDROID_MANIFEST = "AndroidManifest.xml"; diff --git a/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java b/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java index 190495e21..e1161acba 100644 --- a/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java +++ b/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java @@ -76,9 +76,6 @@ public class ZipUtils { } public static void signZip(JarMap input, OutputStream output, boolean minSign) throws Exception { - AssetManager assets = MagiskManager.get().getAssets(); - SignAPK.signZip( - assets.open(Const.PUBLIC_KEY_NAME), assets.open(Const.PRIVATE_KEY_NAME), - input, output, minSign); + SignAPK.signZip(null, null, input, output, minSign); } -} \ No newline at end of file +}