soul-browser/sources/java/com/google/android/gms/internal/ads/zzhwx.java
KaKi87 550ddb0413
Decompile and recreate Soul Browser v1.4.85 with APK CI builds (#1)
* 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>
2026-08-10 16:07:14 +02:00

164 lines
7.9 KiB
Java

package com.google.android.gms.internal.ads;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.interfaces.RSAPublicKey;
import java.util.Arrays;
/* loaded from: classes.dex */
final class zzhwx implements zzhaq {
/* renamed from: a, reason: collision with root package name */
public final RSAPublicKey f8858a;
public final zzhwl b;
/* renamed from: c, reason: collision with root package name */
public final zzhwl f8859c;
public final int d;
public final byte[] e;
public final byte[] f;
public /* synthetic */ zzhwx(RSAPublicKey rSAPublicKey, zzhwl zzhwlVar, zzhwl zzhwlVar2, int i, byte[] bArr, byte[] bArr2) {
if (!zzhhc.a()) {
zzhxa.b(zzhwlVar);
if (zzhwlVar.equals(zzhwlVar2)) {
zzhxa.c(rSAPublicKey.getModulus().bitLength());
zzhxa.d(rSAPublicKey.getPublicExponent());
this.f8858a = rSAPublicKey;
this.b = zzhwlVar;
this.f8859c = zzhwlVar2;
this.d = i;
this.e = bArr;
this.f = bArr2;
return;
}
throw new GeneralSecurityException("sigHash and mgf1Hash must be the same");
}
throw new GeneralSecurityException("Can not use RSA PSS in FIPS-mode, as BoringCrypto module is not available.");
}
@Override // com.google.android.gms.internal.ads.zzhaq
public final void a(byte[] bArr, byte[] bArr2) {
byte[] bArr3 = this.e;
int length = bArr3.length;
if (length == 0) {
b(bArr, bArr2);
} else {
if (zzhkl.c(bArr3, bArr)) {
b(Arrays.copyOfRange(bArr, length, bArr.length), bArr2);
return;
}
throw new GeneralSecurityException("Invalid signature (output prefix mismatch)");
}
}
public final void b(byte[] bArr, byte[] bArr2) {
RSAPublicKey rSAPublicKey = this.f8858a;
BigInteger publicExponent = rSAPublicKey.getPublicExponent();
BigInteger modulus = rSAPublicKey.getModulus();
int bitLength = modulus.bitLength() + 7;
int bitLength2 = modulus.bitLength() + 6;
if (bitLength / 8 == bArr.length) {
BigInteger bigInteger = new BigInteger(1, bArr);
if (bigInteger.compareTo(modulus) < 0) {
byte[] b = zzhhe.b(bigInteger.modPow(publicExponent, modulus), bitLength2 / 8);
int bitLength3 = modulus.bitLength() - 1;
zzhwl zzhwlVar = this.b;
zzhxa.b(zzhwlVar);
zzhwc zzhwcVar = zzhwc.e;
MessageDigest messageDigest = (MessageDigest) zzhwcVar.f8846a.zza(zzhwz.a(zzhwlVar));
messageDigest.update(bArr2);
byte[] bArr3 = this.f;
if (bArr3.length != 0) {
messageDigest.update(bArr3);
}
byte[] digest = messageDigest.digest();
int digestLength = messageDigest.getDigestLength();
int length = b.length;
int i = this.d;
if (length >= digestLength + i + 2) {
if (b[length - 1] == -68) {
int i2 = length - digestLength;
int i3 = i2 - 1;
byte[] copyOf = Arrays.copyOf(b, i3);
int length2 = copyOf.length;
byte[] copyOfRange = Arrays.copyOfRange(b, length2, length2 + digestLength);
int i4 = 0;
while (true) {
long j = (length * 8) - bitLength3;
if (i4 < j) {
if (((copyOf[i4 / 8] >> (7 - (i4 % 8))) & 1) == 0) {
i4++;
} else {
throw new GeneralSecurityException("inconsistent");
}
} else {
MessageDigest messageDigest2 = (MessageDigest) zzhwcVar.f8846a.zza(zzhwz.a(this.f8859c));
int digestLength2 = messageDigest2.getDigestLength();
byte[] bArr4 = new byte[i3];
int i5 = 0;
int i6 = 0;
while (i5 <= (i2 - 2) / digestLength2) {
messageDigest2.reset();
messageDigest2.update(copyOfRange);
int i7 = i;
messageDigest2.update(zzhhe.b(BigInteger.valueOf(i5), 4));
byte[] digest2 = messageDigest2.digest();
int length3 = digest2.length;
System.arraycopy(digest2, 0, bArr4, i6, Math.min(length3, i3 - i6));
i6 += length3;
i5++;
i = i7;
messageDigest2 = messageDigest2;
}
int i8 = i;
byte[] bArr5 = new byte[i3];
for (int i9 = 0; i9 < i3; i9++) {
bArr5[i9] = (byte) (bArr4[i9] ^ copyOf[i9]);
}
for (int i10 = 0; i10 <= j; i10++) {
int i11 = i10 / 8;
bArr5[i11] = (byte) ((~(1 << (7 - (i10 % 8)))) & bArr5[i11]);
}
int i12 = 0;
while (true) {
int i13 = (i2 - i8) - 2;
if (i12 < i13) {
if (bArr5[i12] == 0) {
i12++;
} else {
throw new GeneralSecurityException("inconsistent");
}
} else {
if (bArr5[i13] == 1) {
byte[] copyOfRange2 = Arrays.copyOfRange(bArr5, i3 - i8, i3);
int i14 = digestLength + 8;
byte[] bArr6 = new byte[i14 + i8];
System.arraycopy(digest, 0, bArr6, 8, digest.length);
System.arraycopy(copyOfRange2, 0, bArr6, i14, copyOfRange2.length);
if (MessageDigest.isEqual(messageDigest.digest(bArr6), copyOfRange)) {
return;
} else {
throw new GeneralSecurityException("inconsistent");
}
}
throw new GeneralSecurityException("inconsistent");
}
}
}
}
} else {
throw new GeneralSecurityException("inconsistent");
}
} else {
throw new GeneralSecurityException("inconsistent");
}
} else {
throw new GeneralSecurityException("signature out of range");
}
} else {
throw new GeneralSecurityException("invalid signature's length");
}
}
}