Update with latest :crypto
This commit is contained in:
parent
40082d4571
commit
f37f330670
@ -205,11 +205,9 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
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);
|
||||
}
|
||||
|
@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user