Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix java9+ #13

Merged
merged 1 commit into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/orig/SignApk.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;

import sun.misc.BASE64Encoder;
import java.util.Base64;
import sun.security.pkcs.ContentInfo;
import sun.security.pkcs.PKCS7;
import sun.security.pkcs.SignerInfo;
Expand Down Expand Up @@ -179,7 +179,7 @@ private static Manifest addDigestsToManifest(JarFile jar)
main.putValue("Manifest-Version", "1.0");
}

BASE64Encoder base64 = new BASE64Encoder();
Base64.Encoder base64 = Base64.getEncoder().withoutPadding();
MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] buffer = new byte[4096];
int num;
Expand Down Expand Up @@ -210,7 +210,7 @@ private static Manifest addDigestsToManifest(JarFile jar)
Attributes attr = null;
if (input != null) attr = input.getAttributes(name);
attr = attr != null ? new Attributes(attr) : new Attributes();
attr.putValue("SHA1-Digest", base64.encode(md.digest()));
attr.putValue("SHA1-Digest", base64.encodeToString(md.digest()));
output.getEntries().put(name, attr);
}
}
Expand All @@ -230,7 +230,7 @@ private static void addOtacert(JarOutputStream outputJar,
long timestamp,
Manifest manifest)
throws IOException, GeneralSecurityException {
BASE64Encoder base64 = new BASE64Encoder();
Base64.Encoder base64 = Base64.getEncoder().withoutPadding();
MessageDigest md = MessageDigest.getInstance("SHA1");

JarEntry je = new JarEntry(OTACERT_NAME);
Expand All @@ -246,7 +246,7 @@ private static void addOtacert(JarOutputStream outputJar,
input.close();

Attributes attr = new Attributes();
attr.putValue("SHA1-Digest", base64.encode(md.digest()));
attr.putValue("SHA1-Digest", base64.encodeToString(md.digest()));
manifest.getEntries().put(OTACERT_NAME, attr);
}

Expand Down Expand Up @@ -296,7 +296,7 @@ private static void writeSignatureFile(Manifest manifest, SignatureOutputStream
Attributes main = sf.getMainAttributes();
main.putValue("Signature-Version", "1.0");

BASE64Encoder base64 = new BASE64Encoder();
Base64.Encoder base64 = Base64.getEncoder().withoutPadding();
MessageDigest md = MessageDigest.getInstance("SHA1");
PrintStream print = new PrintStream(
new DigestOutputStream(new ByteArrayOutputStream(), md),
Expand All @@ -305,7 +305,7 @@ private static void writeSignatureFile(Manifest manifest, SignatureOutputStream
// Digest of the entire manifest
manifest.write(print);
print.flush();
main.putValue("SHA1-Digest-Manifest", base64.encode(md.digest()));
main.putValue("SHA1-Digest-Manifest", base64.encodeToString(md.digest()));

Map<String, Attributes> entries = manifest.getEntries();
for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
Expand All @@ -318,7 +318,7 @@ private static void writeSignatureFile(Manifest manifest, SignatureOutputStream
print.flush();

Attributes sfAttr = new Attributes();
sfAttr.putValue("SHA1-Digest", base64.encode(md.digest()));
sfAttr.putValue("SHA1-Digest", base64.encodeToString(md.digest()));
sf.getEntries().put(entry.getKey(), sfAttr);
}

Expand Down
16 changes: 8 additions & 8 deletions src/s/Sign.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import java.util.jar.Manifest;
import java.util.regex.Pattern;

import sun.misc.BASE64Encoder;
import java.util.Base64;
import sun.security.pkcs.ContentInfo;
import sun.security.pkcs.PKCS7;
import sun.security.pkcs.SignerInfo;
Expand Down Expand Up @@ -105,7 +105,7 @@ private static Manifest addDigestsToManifest(JarFile jar) throws IOException,
main.putValue("Manifest-Version", "1.0");
}

BASE64Encoder base64 = new BASE64Encoder();
Base64.Encoder base64 = Base64.getEncoder().withoutPadding();
MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] buffer = new byte[4096];
int num;
Expand Down Expand Up @@ -136,7 +136,7 @@ private static Manifest addDigestsToManifest(JarFile jar) throws IOException,
if (input != null)
attr = input.getAttributes(name);
attr = attr != null ? new Attributes(attr) : new Attributes();
attr.putValue("SHA1-Digest", base64.encode(md.digest()));
attr.putValue("SHA1-Digest", base64.encodeToString(md.digest()));
output.getEntries().put(name, attr);
}
}
Expand All @@ -154,7 +154,7 @@ private static void addOtacert(JarOutputStream outputJar, long timestamp,
Manifest manifest) throws IOException, GeneralSecurityException {
final InputStream input = new ByteArrayInputStream(publicBytes);

BASE64Encoder base64 = new BASE64Encoder();
Base64.Encoder base64 = Base64.getEncoder().withoutPadding();
MessageDigest md = MessageDigest.getInstance("SHA1");

JarEntry je = new JarEntry(OTACERT_NAME);
Expand All @@ -170,7 +170,7 @@ private static void addOtacert(JarOutputStream outputJar, long timestamp,
input.close();

Attributes attr = new Attributes();
attr.putValue("SHA1-Digest", base64.encode(md.digest()));
attr.putValue("SHA1-Digest", base64.encodeToString(md.digest()));
manifest.getEntries().put(OTACERT_NAME, attr);
}

Expand Down Expand Up @@ -219,15 +219,15 @@ private static void writeSignatureFile(Manifest manifest,
Attributes main = sf.getMainAttributes();
main.putValue("Signature-Version", "1.0");

BASE64Encoder base64 = new BASE64Encoder();
Base64.Encoder base64 = Base64.getEncoder().withoutPadding();
MessageDigest md = MessageDigest.getInstance("SHA1");
PrintStream print = new PrintStream(new DigestOutputStream(
new ByteArrayOutputStream(), md), true, "UTF-8");

// Digest of the entire manifest
manifest.write(print);
print.flush();
main.putValue("SHA1-Digest-Manifest", base64.encode(md.digest()));
main.putValue("SHA1-Digest-Manifest", base64.encodeToString(md.digest()));

Map<String, Attributes> entries = manifest.getEntries();
for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
Expand All @@ -240,7 +240,7 @@ private static void writeSignatureFile(Manifest manifest,
print.flush();

Attributes sfAttr = new Attributes();
sfAttr.putValue("SHA1-Digest", base64.encode(md.digest()));
sfAttr.putValue("SHA1-Digest", base64.encodeToString(md.digest()));
sf.getEntries().put(entry.getKey(), sfAttr);
}

Expand Down