Update crypto
This commit is contained in:
parent
e8302dfbe2
commit
97cf15007f
2
app
2
app
@ -1 +1 @@
|
|||||||
Subproject commit 759e905c3c61018ae736e313d0272e215086f6e2
|
Subproject commit 00d655f346fe6182d508d76d6b75d8e7357fcb9d
|
@ -70,9 +70,8 @@ public class SignAPK {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void signZip(InputStream publicIn, InputStream privateIn,
|
public static void signZip(InputStream publicIn, InputStream privateIn,
|
||||||
JarMap input, File output, boolean minSign) throws Exception {
|
JarMap input, OutputStream output, boolean minSign) throws Exception {
|
||||||
int alignment = 4;
|
int alignment = 4;
|
||||||
BufferedOutputStream outputFile;
|
|
||||||
int hashes = 0;
|
int hashes = 0;
|
||||||
X509Certificate publicKey = CryptoUtils.readPublicKey(publicIn);
|
X509Certificate publicKey = CryptoUtils.readPublicKey(publicIn);
|
||||||
hashes |= getDigestAlgorithm(publicKey);
|
hashes |= getDigestAlgorithm(publicKey);
|
||||||
@ -83,11 +82,10 @@ public class SignAPK {
|
|||||||
long timestamp = publicKey.getNotBefore().getTime() + 3600L * 1000;
|
long timestamp = publicKey.getNotBefore().getTime() + 3600L * 1000;
|
||||||
PrivateKey privateKey = CryptoUtils.readPrivateKey(privateIn);
|
PrivateKey privateKey = CryptoUtils.readPrivateKey(privateIn);
|
||||||
|
|
||||||
outputFile = new BufferedOutputStream(new FileOutputStream(output));
|
|
||||||
if (minSign) {
|
if (minSign) {
|
||||||
signWholeFile(input.getFile(), publicKey, privateKey, outputFile);
|
signWholeFile(input.getFile(), publicKey, privateKey, output);
|
||||||
} else {
|
} else {
|
||||||
JarOutputStream outputJar = new JarOutputStream(outputFile);
|
JarOutputStream outputJar = new JarOutputStream(output);
|
||||||
// For signing .apks, use the maximum compression to make
|
// For signing .apks, use the maximum compression to make
|
||||||
// them as small as possible (since they live forever on
|
// them as small as possible (since they live forever on
|
||||||
// the system partition). For OTA packages, use the
|
// the system partition). For OTA packages, use the
|
||||||
@ -98,10 +96,7 @@ public class SignAPK {
|
|||||||
Manifest manifest = addDigestsToManifest(input, hashes);
|
Manifest manifest = addDigestsToManifest(input, hashes);
|
||||||
copyFiles(manifest, input, outputJar, timestamp, alignment);
|
copyFiles(manifest, input, outputJar, timestamp, alignment);
|
||||||
signFile(manifest, input, publicKey, privateKey, outputJar);
|
signFile(manifest, input, publicKey, privateKey, outputJar);
|
||||||
outputJar.close();
|
|
||||||
}
|
}
|
||||||
input.close();
|
|
||||||
outputFile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,8 +2,10 @@ package com.topjohnwu.crypto;
|
|||||||
|
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
|
||||||
@ -32,8 +34,9 @@ public class ZipSigner {
|
|||||||
|
|
||||||
try (InputStream pub = new FileInputStream(pubKey);
|
try (InputStream pub = new FileInputStream(pubKey);
|
||||||
InputStream priv = new FileInputStream(privKey);
|
InputStream priv = new FileInputStream(privKey);
|
||||||
JarMap jar = new JarMap(input, false)) {
|
JarMap jar = new JarMap(input, false);
|
||||||
SignAPK.signZip(pub, priv, jar, output, minSign);
|
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(output))) {
|
||||||
|
SignAPK.signZip(pub, priv, jar, out, minSign);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user