Files
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

71 lines
2.6 KiB
Java

package com.firemonkeys.cloudcellapi.util;
import android.text.TextUtils;
import android.util.Log;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
/* loaded from: classes2.dex */
public class Security {
private static final String KEY_FACTORY_ALGORITHM = "RSA";
private static final String SIGNATURE_ALGORITHM = "SHA1withRSA";
private static final String TAG = "IABUtil/Security";
public static boolean verifyPurchase(String str, String str2, String str3) {
if (str2 == null) {
Log.e(TAG, "data is null");
return false;
}
if (TextUtils.isEmpty(str3) || verify(generatePublicKey(str), str2, str3)) {
return true;
}
Log.w(TAG, "signature does not match data.");
return false;
}
public static PublicKey generatePublicKey(String str) {
try {
return KeyFactory.getInstance(KEY_FACTORY_ALGORITHM).generatePublic(new X509EncodedKeySpec(Base64.decode(str)));
} catch (Base64DecoderException e) {
Log.e(TAG, "Base64 decoding failed.");
throw new IllegalArgumentException(e);
} catch (NoSuchAlgorithmException e2) {
throw new RuntimeException(e2);
} catch (InvalidKeySpecException e3) {
Log.e(TAG, "Invalid key specification.");
throw new IllegalArgumentException(e3);
}
}
public static boolean verify(PublicKey publicKey, String str, String str2) {
try {
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
signature.initVerify(publicKey);
signature.update(str.getBytes());
if (signature.verify(Base64.decode(str2))) {
return true;
}
Log.e(TAG, "Signature verification failed.");
return false;
} catch (Base64DecoderException unused) {
Log.e(TAG, "Base64 decoding failed.");
return false;
} catch (InvalidKeyException unused2) {
Log.e(TAG, "Invalid key specification.");
return false;
} catch (NoSuchAlgorithmException unused3) {
Log.e(TAG, "NoSuchAlgorithmException.");
return false;
} catch (SignatureException unused4) {
Log.e(TAG, "Signature exception.");
return false;
}
}
}