* Decompile and recreate Soul Browser v1.4.85 with APK CI builds Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix CI build: include bundled google.jks and remove PR trigger The apktool build failed in CI because app/unknown/.../google.jks was excluded by the *.jks gitignore rule. Whitelist app-bundled JKS files and commit the missing resource. Also remove the redundant pull_request workflow trigger. Co-authored-by: KaKi87 <KaKi87@pm.me> * Change package ID to com.github.kaki87.soulbrowser Rename the application ID so the rebuilt APK can be installed alongside the original Soul Browser from Google Play. - Update AndroidManifest package, permissions, providers, and actions - Update R class references in smali (com/github/kaki87/soulbrowser/R) - Update shortcuts.xml targetPackage - Rename app label to "Soul Rebuild" for easy identification Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix install compatibility: remove split APK metadata and bundle native libs The rebuilt APK still declared requiredSplitTypes and Play Store split metadata, causing Android to reject standalone installs as incompatible. - Remove requiredSplitTypes and split-related manifest meta-data - Merge native libs from all ABI splits with uncompressed storage - Page-align before signing for extractNativeLibs=false - Add .so to apktool doNotCompress list Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix install failure: use apksigner v2/v3 and bundle arm64 native libs Target SDK 36 requires APK Signature Scheme v2+, but jarsigner only produces v1 signatures, causing Android to reject the install. - Sign with apksigner (v1+v2+v3) instead of jarsigner - Add arm64-v8a native libraries from universal Soul Browser 1.4.79 - Set extractNativeLibs=true for reliable sideload installs - Commit stable debug keystore for consistent signatures across builds Co-authored-by: KaKi87 <KaKi87@pm.me> * Add committed debug keystore for consistent APK signatures Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix startup crash: use original classes2.dex desugar libraries Apktool recompiles smali_classes2 into a broken classes2.dex, causing ClassNotFoundException for j$.com.android.tools.r8.a at ML Kit init. Inject the original classes2.dex (Java 8+ desugar libs) after apktool build instead of using the recompiled version. Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix missing drawable resources from density split APKs The base APK is an app bundle module; density-specific drawables like seek_thumb_nor_b live in config.xhdpi.apk and were missing after rebuild, causing Resources$NotFoundException at runtime. - Merge non-9-patch resources from split APKs before apktool build - Sync public.xml IDs from R smali only when backing files exist - Add 713 density-specific resource IDs to public.xml Co-authored-by: KaKi87 <KaKi87@pm.me> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
160 lines
6.1 KiB
Java
160 lines
6.1 KiB
Java
package com.google.api.client.util;
|
|
|
|
import com.google.api.client.util.PemReader;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.security.KeyFactory;
|
|
import java.security.KeyStore;
|
|
import java.security.PrivateKey;
|
|
import java.security.PublicKey;
|
|
import java.security.Signature;
|
|
import java.security.SignatureException;
|
|
import java.security.cert.Certificate;
|
|
import java.security.cert.CertificateException;
|
|
import java.security.cert.CertificateFactory;
|
|
import java.security.cert.X509Certificate;
|
|
import java.security.spec.PKCS8EncodedKeySpec;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import javax.net.ssl.X509TrustManager;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class SecurityUtils {
|
|
private SecurityUtils() {
|
|
}
|
|
|
|
@Beta
|
|
public static KeyStore createMtlsKeyStore(InputStream inputStream) {
|
|
KeyStore keyStore = KeyStore.getInstance("JKS");
|
|
PemReader.Section section = null;
|
|
keyStore.load(null);
|
|
PemReader pemReader = new PemReader(new InputStreamReader(inputStream));
|
|
PemReader.Section section2 = null;
|
|
while (true) {
|
|
if (section != null && section2 != null) {
|
|
break;
|
|
}
|
|
PemReader.Section readNextSection = pemReader.readNextSection();
|
|
if (readNextSection == null) {
|
|
break;
|
|
}
|
|
if (section == null && "CERTIFICATE".equals(readNextSection.getTitle())) {
|
|
section = readNextSection;
|
|
} else if ("PRIVATE KEY".equals(readNextSection.getTitle())) {
|
|
section2 = readNextSection;
|
|
}
|
|
}
|
|
if (section != null) {
|
|
if (section2 != null) {
|
|
X509Certificate x509Certificate = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(section.getBase64DecodedBytes()));
|
|
keyStore.setKeyEntry("alias", KeyFactory.getInstance(x509Certificate.getPublicKey().getAlgorithm()).generatePrivate(new PKCS8EncodedKeySpec(section2.getBase64DecodedBytes())), new char[0], new X509Certificate[]{x509Certificate});
|
|
return keyStore;
|
|
}
|
|
throw new IllegalArgumentException("private key is missing from certAndKey string");
|
|
}
|
|
throw new IllegalArgumentException("certificate is missing from certAndKey string");
|
|
}
|
|
|
|
public static KeyStore getDefaultKeyStore() {
|
|
return KeyStore.getInstance(KeyStore.getDefaultType());
|
|
}
|
|
|
|
public static Signature getEs256SignatureAlgorithm() {
|
|
return Signature.getInstance("SHA256withECDSA");
|
|
}
|
|
|
|
public static KeyStore getJavaKeyStore() {
|
|
return KeyStore.getInstance("JKS");
|
|
}
|
|
|
|
public static KeyStore getPkcs12KeyStore() {
|
|
return KeyStore.getInstance("PKCS12");
|
|
}
|
|
|
|
public static PrivateKey getPrivateKey(KeyStore keyStore, String str, String str2) {
|
|
return (PrivateKey) keyStore.getKey(str, str2.toCharArray());
|
|
}
|
|
|
|
public static KeyFactory getRsaKeyFactory() {
|
|
return KeyFactory.getInstance("RSA");
|
|
}
|
|
|
|
public static Signature getSha1WithRsaSignatureAlgorithm() {
|
|
return Signature.getInstance("SHA1withRSA");
|
|
}
|
|
|
|
public static Signature getSha256WithRsaSignatureAlgorithm() {
|
|
return Signature.getInstance("SHA256withRSA");
|
|
}
|
|
|
|
public static CertificateFactory getX509CertificateFactory() {
|
|
return CertificateFactory.getInstance("X.509");
|
|
}
|
|
|
|
public static void loadKeyStore(KeyStore keyStore, InputStream inputStream, String str) {
|
|
try {
|
|
keyStore.load(inputStream, str.toCharArray());
|
|
} finally {
|
|
inputStream.close();
|
|
}
|
|
}
|
|
|
|
public static void loadKeyStoreFromCertificates(KeyStore keyStore, CertificateFactory certificateFactory, InputStream inputStream) {
|
|
Iterator<? extends Certificate> it = certificateFactory.generateCertificates(inputStream).iterator();
|
|
int i = 0;
|
|
while (it.hasNext()) {
|
|
keyStore.setCertificateEntry(String.valueOf(i), it.next());
|
|
i++;
|
|
}
|
|
}
|
|
|
|
public static PrivateKey loadPrivateKeyFromKeyStore(KeyStore keyStore, InputStream inputStream, String str, String str2, String str3) {
|
|
loadKeyStore(keyStore, inputStream, str);
|
|
return getPrivateKey(keyStore, str2, str3);
|
|
}
|
|
|
|
public static byte[] sign(Signature signature, PrivateKey privateKey, byte[] bArr) {
|
|
signature.initSign(privateKey);
|
|
signature.update(bArr);
|
|
return signature.sign();
|
|
}
|
|
|
|
public static boolean verify(Signature signature, PublicKey publicKey, byte[] bArr, byte[] bArr2) {
|
|
signature.initVerify(publicKey);
|
|
signature.update(bArr2);
|
|
try {
|
|
return signature.verify(bArr);
|
|
} catch (SignatureException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static X509Certificate verify(Signature signature, X509TrustManager x509TrustManager, List<String> list, byte[] bArr, byte[] bArr2) {
|
|
try {
|
|
CertificateFactory x509CertificateFactory = getX509CertificateFactory();
|
|
X509Certificate[] x509CertificateArr = new X509Certificate[list.size()];
|
|
Iterator<String> it = list.iterator();
|
|
int i = 0;
|
|
while (it.hasNext()) {
|
|
try {
|
|
Certificate generateCertificate = x509CertificateFactory.generateCertificate(new ByteArrayInputStream(Base64.decodeBase64(it.next())));
|
|
if (!(generateCertificate instanceof X509Certificate)) {
|
|
return null;
|
|
}
|
|
int i2 = i + 1;
|
|
x509CertificateArr[i] = (X509Certificate) generateCertificate;
|
|
i = i2;
|
|
} catch (CertificateException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
x509TrustManager.checkServerTrusted(x509CertificateArr, "RSA");
|
|
if (verify(signature, x509CertificateArr[0].getPublicKey(), bArr, bArr2)) {
|
|
return x509CertificateArr[0];
|
|
}
|
|
} catch (CertificateException unused2) {
|
|
}
|
|
return null;
|
|
}
|
|
}
|