179 lines
6.5 KiB
Java
179 lines
6.5 KiB
Java
package o;
|
|
|
|
import com.eracom.OBM2.EncryptedMessageException;
|
|
import java.security.InvalidKeyException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.PublicKey;
|
|
import java.security.spec.InvalidKeySpecException;
|
|
import java.util.Properties;
|
|
import javax.crypto.BadPaddingException;
|
|
import javax.crypto.Cipher;
|
|
import javax.crypto.IllegalBlockSizeException;
|
|
import javax.crypto.NoSuchPaddingException;
|
|
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class YWp {
|
|
public int c;
|
|
private int d = 3;
|
|
|
|
private static String[] a(String[] strArr, int i) {
|
|
String[] strArr2 = new String[i];
|
|
int i2 = 0;
|
|
while (i2 < i) {
|
|
strArr2[i2] = i2 < strArr.length ? strArr[i2] : strArr2[i2 - 1];
|
|
i2++;
|
|
}
|
|
return strArr2;
|
|
}
|
|
|
|
public final String c(String str, String str2, String str3, Properties properties) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
|
|
if (properties.containsKey("HASH_MODE")) {
|
|
properties.getProperty("HASH_MODE");
|
|
C10776eOe e = new bFB().e(str, str3);
|
|
int i = e.d;
|
|
this.c = i;
|
|
return i == 0 ? e.c : "";
|
|
}
|
|
if (properties.containsKey("PinFormat")) {
|
|
String property = properties != null ? properties.getProperty("PinFormat") : null;
|
|
if ("SHA256".equals(property)) {
|
|
return a(str, str3, properties);
|
|
}
|
|
throw new NoSuchAlgorithmException("Unsupported PinFormat: ".concat(String.valueOf(property)));
|
|
}
|
|
TGe a = a(str);
|
|
if (a != null && (a.a == null || a.e == null)) {
|
|
return null;
|
|
}
|
|
C15605gzv c15605gzv = new C15605gzv(a.e, a.a);
|
|
int b = c15605gzv.b(str3, str2, properties);
|
|
this.c = b;
|
|
if (b != 0) {
|
|
return "";
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(c15605gzv.e);
|
|
sb.append(":");
|
|
sb.append(c15605gzv.d);
|
|
return sb.toString();
|
|
}
|
|
|
|
public static String a(String str, String str2, Properties properties) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
|
|
int parseInt = properties != null ? Integer.parseInt(properties.getProperty("AlgorithmID"), 16) : 0;
|
|
if (parseInt != 1) {
|
|
throw new NoSuchAlgorithmException("Unsupported AlgorithmID: ".concat(String.valueOf(parseInt)));
|
|
}
|
|
byte[] e = VBO.e(McElieceCCA2KeyGenParameterSpec.SHA256, str2.getBytes());
|
|
PublicKey e2 = VBO.e(str);
|
|
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
|
cipher.init(1, e2);
|
|
return Ymn.b(cipher.doFinal(e));
|
|
}
|
|
|
|
public final TGe a(String str) {
|
|
try {
|
|
return new TGe(str);
|
|
} catch (EncryptedMessageException e) {
|
|
String message = e.getMessage();
|
|
int indexOf = message.indexOf("Error no : ");
|
|
int parseInt = Integer.parseInt(message.substring(indexOf + 11, indexOf + 13));
|
|
System.out.println(message);
|
|
this.c = parseInt;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Properties e(Properties properties, String str, String str2) {
|
|
int indexOf = str2.indexOf(58);
|
|
if (indexOf > 0) {
|
|
String[] split = str2.substring(0, indexOf).split(",");
|
|
str = split[0];
|
|
if (!"PKCS1Padding".equals(split[1])) {
|
|
StringBuilder sb = new StringBuilder("Unsupported algo: ");
|
|
sb.append(split[1]);
|
|
throw new RuntimeException(sb.toString());
|
|
}
|
|
properties.setProperty("AlgorithmID", Integer.toHexString(1));
|
|
}
|
|
if (str != null) {
|
|
if ("ISO-0".equalsIgnoreCase(str)) {
|
|
properties.setProperty("param_ISO_FORMAT_0_PAN", str2);
|
|
} else if ("NONE-SHORT".equalsIgnoreCase(str)) {
|
|
properties.setProperty("HASH_MODE", "NONE-SHORT");
|
|
} else {
|
|
properties.setProperty("PinFormat", str);
|
|
}
|
|
}
|
|
return properties;
|
|
}
|
|
|
|
public final String d(byte b, String str, String str2, String str3, String str4) throws Exception {
|
|
String[] split = str.split(";");
|
|
int length = split.length;
|
|
if (length < 0) {
|
|
length = 0;
|
|
}
|
|
String[] split2 = str2.split("\t");
|
|
int length2 = split2.length;
|
|
if (length <= length2) {
|
|
length = length2;
|
|
}
|
|
String[] split3 = str3.split(";");
|
|
int length3 = split3.length;
|
|
if (length <= length3) {
|
|
length = length3;
|
|
}
|
|
String[] split4 = str4.split(";");
|
|
int length4 = split4.length;
|
|
if (length <= length4) {
|
|
length = length4;
|
|
}
|
|
String[] strArr = new String[1];
|
|
if (length <= 1) {
|
|
length = 1;
|
|
}
|
|
String[] a = a(split, length);
|
|
String[] a2 = a(split2, length);
|
|
String[] a3 = a(split3, length);
|
|
String[] a4 = a(split4, length);
|
|
String[] a5 = a(strArr, length);
|
|
byte[] bArr = {b};
|
|
byte[] bArr2 = new byte[length];
|
|
int i = 0;
|
|
while (i < length) {
|
|
bArr2[i] = i < 1 ? bArr[i] : bArr2[i - 1];
|
|
i++;
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i2 = 0; i2 < a.length; i2++) {
|
|
byte b2 = bArr2[i2];
|
|
Properties properties = new Properties();
|
|
properties.setProperty("AlgorithmID", Integer.toHexString(b2));
|
|
Properties e = e(properties, a5[i2], a4[i2]);
|
|
String c = c(a3[i2], a4[i2], a2[i2], e);
|
|
if (this.c != 0) {
|
|
return null;
|
|
}
|
|
if ("ISO-0".equals(a5[i2])) {
|
|
String c2 = c(a3[i2], a4[i2], a2[i2], e(new Properties(e), "NONE-SHORT", a4[i2]));
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.append(c2);
|
|
sb2.append(',');
|
|
sb2.append(c);
|
|
c = sb2.toString();
|
|
}
|
|
if (this.c != 0) {
|
|
return null;
|
|
}
|
|
if (i2 > 0) {
|
|
sb.append(';');
|
|
}
|
|
sb.append(a[i2]);
|
|
sb.append(',');
|
|
sb.append(c);
|
|
}
|
|
return sb.toString();
|
|
}
|
|
}
|