what-the-bank/sources/o/xZE.java

133 lines
5.6 KiB
Java

package o;
import java.math.BigInteger;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPublicKeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.OAEPParameterSpec;
import javax.crypto.spec.PSource;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
/* loaded from: classes3.dex */
public final class xZE {
private static final IvParameterSpec d;
private static final IvParameterSpec e;
static {
String property;
C17796znh.c("secret00");
try {
if (Security.getProvider("SunJCE") == null) {
Security.addProvider((Provider) Class.forName("com.sun.crypto.provider.SunJCE").newInstance());
}
} catch (Throwable unused) {
}
try {
if (Security.getProvider("IBMJCE") == null) {
Security.addProvider((Provider) Class.forName("com.ibm.crypto.provider.IBMJCE").newInstance());
}
} catch (Throwable unused2) {
}
try {
if (Security.getProvider("IBMJCA") == null) {
Security.addProvider((Provider) Class.forName("com.ibm.crypto.provider.IBMJCA").newInstance());
}
} catch (Throwable unused3) {
}
try {
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
Security.addProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance());
}
} catch (Throwable unused4) {
}
for (int i = 1; i <= 100 && (property = System.getProperty("isprint.security.provider.".concat(String.valueOf(i)))) != null && property.length() >= 0; i++) {
try {
Security.addProvider((Provider) Class.forName(property).newInstance());
} catch (Throwable unused5) {
}
}
e = new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
d = new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
new SecureRandom();
}
public static byte[] c(int i) {
byte[] bArr = new byte[i];
new SecureRandom().nextBytes(bArr);
return bArr;
}
public static byte[] e(String str, byte[] bArr) throws NoSuchAlgorithmException {
MessageDigest messageDigest = MessageDigest.getInstance(str);
messageDigest.update(bArr);
return messageDigest.digest();
}
public static Key c(byte[] bArr, String str) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException {
return new SecretKeySpec(bArr, str);
}
public static Key b(String str) {
try {
String[] split = str.split(",", 2);
return KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(1, C17796znh.d(split[0])), new BigInteger(1, C17796znh.d(split[1]))));
} catch (Exception e2) {
throw new IllegalArgumentException("Failed to restore RSA key", e2);
}
}
public static byte[] b(Key key, byte[] bArr, String str, byte[] bArr2) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
IvParameterSpec ivParameterSpec;
OAEPParameterSpec oAEPParameterSpec;
Cipher cipher = Cipher.getInstance(str);
if (str.indexOf("/OAEPWithSHA1AndMGF1Padding") < 0) {
if (str.indexOf("/ECB") >= 0 || str.indexOf("/SSL") >= 0 || str.indexOf("/NONE") >= 0 || str.indexOf(47) < 0) {
cipher.init(1, key);
} else {
int blockSize = cipher.getBlockSize();
if (bArr2 == null || bArr2.length == 0) {
if (blockSize == 8) {
ivParameterSpec = e;
} else if (blockSize == 16) {
ivParameterSpec = d;
} else {
bArr2 = new byte[blockSize];
}
cipher.init(1, key, ivParameterSpec);
} else if (bArr2.length < blockSize && bArr2.length != blockSize) {
byte[] bArr3 = new byte[blockSize];
for (int i = 0; i < bArr2.length && i < blockSize; i++) {
bArr3[i] = bArr2[i];
}
bArr2 = bArr3;
}
ivParameterSpec = new IvParameterSpec(bArr2, 0, blockSize);
cipher.init(1, key, ivParameterSpec);
}
} else {
if (bArr2 == null || bArr2.length == 0) {
oAEPParameterSpec = OAEPParameterSpec.DEFAULT;
} else {
oAEPParameterSpec = new OAEPParameterSpec(OAEPParameterSpec.DEFAULT.getDigestAlgorithm(), OAEPParameterSpec.DEFAULT.getMGFAlgorithm(), OAEPParameterSpec.DEFAULT.getMGFParameters(), new PSource.PSpecified(bArr2));
}
cipher.init(1, key, oAEPParameterSpec);
}
return cipher.doFinal(bArr);
}
}