package org.jmrtd; import android.graphics.Color; import android.text.TextUtils; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.common.primitives.UnsignedBytes; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; import java.math.BigInteger; import java.security.GeneralSecurityException; import java.security.InvalidKeyException; import java.security.KeyFactory; import java.security.MessageDigest; import java.security.PrivateKey; import java.security.Provider; import java.security.PublicKey; import java.security.interfaces.ECPrivateKey; import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.AlgorithmParameterSpec; import java.security.spec.ECField; import java.security.spec.ECFieldF2m; import java.security.spec.ECFieldFp; import java.security.spec.ECParameterSpec; import java.security.spec.ECPoint; import java.security.spec.ECPublicKeySpec; import java.security.spec.EllipticCurve; import java.security.spec.X509EncodedKeySpec; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; import javax.crypto.BadPaddingException; import javax.crypto.SecretKey; import javax.crypto.interfaces.DHPublicKey; import javax.crypto.spec.DHParameterSpec; import net.sf.scuba.tlv.TLVOutputStream; import o.ghS; import o.jTb; import o.xzZ; import org.bouncycastle.asn1.ASN1Encoding; import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1Integer; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.asn1.eac.EACObjectIdentifiers; import org.bouncycastle.asn1.pkcs.DHParameter; import org.bouncycastle.asn1.x509.AlgorithmIdentifier; import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; import org.bouncycastle.asn1.x9.X962NamedCurves; import org.bouncycastle.asn1.x9.X9ECParameters; import org.bouncycastle.crypto.params.DHParameters; import org.bouncycastle.crypto.params.ECDomainParameters; import org.bouncycastle.crypto.params.ECPrivateKeyParameters; import org.bouncycastle.crypto.params.ECPublicKeyParameters; import org.bouncycastle.crypto.tls.CipherSuite; import org.bouncycastle.jce.ECNamedCurveTable; import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec; import org.bouncycastle.jce.spec.ECNamedCurveSpec; import org.bouncycastle.math.ec.ECCurve; import org.bouncycastle.math.ec.ECFieldElement; import org.jmrtd.cbeff.ISO781611; import org.jmrtd.lds.SecurityInfo; import org.jmrtd.lds.icao.MRZInfo; /* loaded from: classes6.dex */ public class Util { private static final Provider BC_PROVIDER; public static final int ENC_MODE = 1; private static final Logger LOGGER; public static final int MAC_MODE = 2; public static final int PACE_MODE = 3; private static int a; private static char b; private static char c; private static char d; private static char e; private static final byte[] $$a = {54, -108, 123, 45}; private static final int $$b = 245; private static int $10 = 0; private static int $11 = 1; private static int f = 1; /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r5v2 */ /* JADX WARN: Type inference failed for: r5v3, types: [int] */ /* JADX WARN: Type inference failed for: r5v6, types: [int] */ /* JADX WARN: Type inference failed for: r5v8 */ /* JADX WARN: Type inference failed for: r5v9 */ private static void h(short s, short s2, byte b2, Object[] objArr) { byte[] bArr = $$a; int i = b2 * 4; int i2 = 67 - s; int i3 = s2 + 4; byte[] bArr2 = new byte[i + 1]; int i4 = -1; byte b3 = i2; if (bArr == null) { int i5 = i2 + i3; i3 = i3; i4 = -1; b3 = i5; } while (true) { int i6 = i4 + 1; bArr2[i6] = b3; if (i6 == i) { objArr[0] = new String(bArr2, 0); return; } int i7 = i3 + 1; b3 = bArr[i7] + b3; i3 = i7; i4 = i6; } } static { a = 0; b(); LOGGER = Logger.getLogger("org.jmrtd"); BC_PROVIDER = JMRTDSecurityProvider.getBouncyCastleProvider(); int i = f + 95; a = i % 128; int i2 = i % 2; } private static void g(char[] cArr, int i, Object[] objArr) { int i2 = 2 % 2; jTb jtb = new jTb(); char[] cArr2 = new char[cArr.length]; int i3 = 0; jtb.b = 0; char[] cArr3 = new char[2]; while (jtb.b < cArr.length) { cArr3[i3] = cArr[jtb.b]; int i4 = 1; cArr3[1] = cArr[jtb.b + 1]; int i5 = $10 + 119; $11 = i5 % 128; int i6 = i5 % 2; int i7 = 58224; int i8 = i3; while (i8 < 16) { int i9 = $11 + 91; $10 = i9 % 128; int i10 = i9 % 2; char c2 = cArr3[i4]; char c3 = cArr3[i3]; char[] cArr4 = cArr3; int i11 = (c3 + i7) ^ ((c3 << 4) + ((char) (e ^ 41718355337583039L))); int i12 = c3 >>> 5; try { Object[] objArr2 = new Object[4]; objArr2[3] = Integer.valueOf(d); objArr2[2] = Integer.valueOf(i12); objArr2[i4] = Integer.valueOf(i11); objArr2[0] = Integer.valueOf(c2); Object obj = xzZ.y.get(597144044); if (obj == null) { Class cls = (Class) xzZ.c((ViewConfiguration.getFadingEdgeLength() >> 16) + 412, 5 - (ViewConfiguration.getMaximumFlingVelocity() >> 16), (char) (TypedValue.complexToFloat(0) > BitmapDescriptorFactory.HUE_RED ? 1 : (TypedValue.complexToFloat(0) == BitmapDescriptorFactory.HUE_RED ? 0 : -1))); byte b2 = (byte) ($$b & 3); byte b3 = (byte) (-b2); Object[] objArr3 = new Object[i4]; h(b2, b3, (byte) (b3 + 1), objArr3); String str = (String) objArr3[0]; Class[] clsArr = new Class[4]; clsArr[0] = Integer.TYPE; clsArr[i4] = Integer.TYPE; clsArr[2] = Integer.TYPE; clsArr[3] = Integer.TYPE; obj = cls.getMethod(str, clsArr); xzZ.y.put(597144044, obj); } char charValue = ((Character) ((Method) obj).invoke(null, objArr2)).charValue(); cArr4[i4] = charValue; int i13 = i8; Object[] objArr4 = {Integer.valueOf(cArr4[0]), Integer.valueOf((charValue + i7) ^ ((charValue << 4) + ((char) (b ^ 41718355337583039L)))), Integer.valueOf(charValue >>> 5), Integer.valueOf(c)}; Object obj2 = xzZ.y.get(597144044); if (obj2 == null) { Class cls2 = (Class) xzZ.c(411 - MotionEvent.axisFromString(""), 4 - TextUtils.lastIndexOf("", '0', 0), (char) (ViewConfiguration.getFadingEdgeLength() >> 16)); byte b4 = (byte) ($$b & 3); byte b5 = (byte) (-b4); Object[] objArr5 = new Object[1]; h(b4, b5, (byte) (b5 + 1), objArr5); obj2 = cls2.getMethod((String) objArr5[0], Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE); xzZ.y.put(597144044, obj2); } cArr4[0] = ((Character) ((Method) obj2).invoke(null, objArr4)).charValue(); i7 -= 40503; i8 = i13 + 1; cArr3 = cArr4; i3 = 0; i4 = 1; } catch (Throwable th) { Throwable cause = th.getCause(); if (cause == null) { throw th; } throw cause; } } char[] cArr5 = cArr3; cArr2[jtb.b] = cArr5[0]; cArr2[jtb.b + 1] = cArr5[1]; Object[] objArr6 = {jtb, jtb}; Object obj3 = xzZ.y.get(943004485); if (obj3 == null) { Class cls3 = (Class) xzZ.c(98 - (ViewConfiguration.getTapTimeout() >> 16), 5 - Color.argb(0, 0, 0, 0), (char) View.MeasureSpec.makeMeasureSpec(0, 0)); byte b6 = (byte) 0; byte b7 = (byte) (b6 - 1); Object[] objArr7 = new Object[1]; h(b6, b7, (byte) (b7 + 1), objArr7); obj3 = cls3.getMethod((String) objArr7[0], Object.class, Object.class); xzZ.y.put(943004485, obj3); } ((Method) obj3).invoke(null, objArr6); cArr3 = cArr5; i3 = 0; } String str2 = new String(cArr2, 0, i); int i14 = $10 + 33; $11 = i14 % 128; int i15 = i14 % 2; objArr[0] = str2; } private Util() { } public static SecretKey deriveKey(byte[] bArr, int i) throws GeneralSecurityException { int i2 = 2 % 2; int i3 = a + 81; f = i3 % 128; return deriveKey(bArr, "DESede", i3 % 2 == 0 ? 7888 : 128, i); } public static SecretKey deriveKey(byte[] bArr, String str, int i, int i2) throws GeneralSecurityException { int i3 = 2 % 2; int i4 = a + 67; f = i4 % 128; int i5 = i4 % 2; SecretKey deriveKey = deriveKey(bArr, str, i, null, i2); int i6 = a + 41; f = i6 % 128; int i7 = i6 % 2; return deriveKey; } /* JADX WARN: Code restructure failed: missing block: B:13:0x006a, code lost: if (r9.startsWith("AES") != false) goto L20; */ /* JADX WARN: Code restructure failed: missing block: B:14:0x0073, code lost: r8 = null; */ /* JADX WARN: Code restructure failed: missing block: B:19:0x0071, code lost: if (r9.startsWith("AES") == false) goto L19; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static javax.crypto.SecretKey deriveKey(byte[] r8, java.lang.String r9, int r10, byte[] r11, int r12) throws java.security.GeneralSecurityException { /* Method dump skipped, instructions count: 235 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: org.jmrtd.Util.deriveKey(byte[], java.lang.String, int, byte[], int):javax.crypto.SecretKey"); } public static byte[] computeKeySeed(String str, String str2, String str3, String str4, boolean z) throws GeneralSecurityException { int i = 2 % 2; StringBuilder sb = new StringBuilder(); sb.append(str); sb.append(MRZInfo.checkDigit(str)); sb.append(str2); sb.append(MRZInfo.checkDigit(str2)); sb.append(str3); sb.append(MRZInfo.checkDigit(str3)); byte[] computeKeySeed = computeKeySeed(sb.toString(), str4, z); int i2 = f + 109; a = i2 % 128; if (i2 % 2 == 0) { return computeKeySeed; } Object obj = null; obj.hashCode(); throw null; } public static byte[] computeKeySeed(String str, String str2, boolean z) throws GeneralSecurityException { int i = 2 % 2; int i2 = a + 107; f = i2 % 128; int i3 = i2 % 2; MessageDigest messageDigest = MessageDigest.getInstance(str2); messageDigest.update(getBytes(str)); byte[] digest = messageDigest.digest(); if (!z) { return digest; } int i4 = f + 81; a = i4 % 128; int i5 = i4 % 2; byte[] bArr = new byte[16]; System.arraycopy(digest, 0, bArr, 0, 16); return bArr; } public static byte[] pad(byte[] bArr, int i) { int i2 = 2 % 2; int i3 = a + 59; f = i3 % 128; byte[] pad = i3 % 2 == 0 ? pad(bArr, 1, bArr.length, i) : pad(bArr, 0, bArr.length, i); int i4 = f + 55; a = i4 % 128; if (i4 % 2 != 0) { int i5 = 17 / 0; } return pad; } public static byte[] pad(byte[] bArr, int i, int i2, int i3) { int i4 = 2 % 2; ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byteArrayOutputStream.write(bArr, i, i2); byteArrayOutputStream.write(-128); while (byteArrayOutputStream.size() % i3 != 0) { int i5 = f + 63; a = i5 % 128; int i6 = i5 % 2; byteArrayOutputStream.write(0); int i7 = f + 7; a = i7 % 128; if (i7 % 2 != 0) { int i8 = 4 / 2; } } return byteArrayOutputStream.toByteArray(); } public static byte[] unpad(byte[] bArr) throws BadPaddingException { int length; int i = 2 % 2; int i2 = a + 63; f = i2 % 128; if (i2 % 2 == 0) { int length2 = bArr.length; length = 0; } else { length = bArr.length - 1; } while (length >= 0 && bArr[length] == 0) { int i3 = f + 5; a = i3 % 128; int i4 = i3 % 2; length--; } if ((bArr[length] & UnsignedBytes.MAX_VALUE) != 128) { StringBuilder sb = new StringBuilder("Expected constant 0x80, found 0x"); sb.append(Integer.toHexString(bArr[length] & UnsignedBytes.MAX_VALUE)); sb.append("\nDEBUG: in = "); sb.append(ghS.c(bArr)); sb.append(", index = "); sb.append(length); throw new BadPaddingException(sb.toString()); } int i5 = f + 69; a = i5 % 128; int i6 = i5 % 2; byte[] bArr2 = new byte[length]; System.arraycopy(bArr, 0, bArr2, 0, length); int i7 = a + 87; f = i7 % 128; int i8 = i7 % 2; return bArr2; } /* JADX WARN: Code restructure failed: missing block: B:10:0x001a, code lost: r2 = r1 + 121; org.jmrtd.Util.a = r2 % 128; r2 = r2 % 2; */ /* JADX WARN: Code restructure failed: missing block: B:11:0x002a, code lost: if (((r9[r9.length - 1] & 15) ^ 12) != 0) goto L40; */ /* JADX WARN: Code restructure failed: missing block: B:12:0x002c, code lost: r2 = r1 + 37; org.jmrtd.Util.a = r2 % 128; r2 = r2 % 2; */ /* JADX WARN: Code restructure failed: missing block: B:13:0x003b, code lost: if (((r9[r9.length - 1] & com.google.common.primitives.UnsignedBytes.MAX_VALUE) ^ 188) != 0) goto L15; */ /* JADX WARN: Code restructure failed: missing block: B:14:0x003d, code lost: r2 = 1; */ /* JADX WARN: Code restructure failed: missing block: B:15:0x004a, code lost: r5 = r9[0]; */ /* JADX WARN: Code restructure failed: missing block: B:16:0x0052, code lost: if (((r5 & net.sf.scuba.smartcards.ISO7816.INS_GET_RESPONSE) ^ 64) != 0) goto L36; */ /* JADX WARN: Code restructure failed: missing block: B:18:0x0056, code lost: if ((r5 & 32) == 0) goto L34; */ /* JADX WARN: Code restructure failed: missing block: B:19:0x0058, code lost: r1 = r1 + 25; org.jmrtd.Util.a = r1 % 128; r1 = r1 % 2; r0 = 0; */ /* JADX WARN: Code restructure failed: missing block: B:21:0x0061, code lost: if (r0 >= r9.length) goto L44; */ /* JADX WARN: Code restructure failed: missing block: B:23:0x0069, code lost: if (((r9[r0] & 15) ^ 10) == 0) goto L45; */ /* JADX WARN: Code restructure failed: missing block: B:24:0x006b, code lost: r0 = r0 + 1; */ /* JADX WARN: Code restructure failed: missing block: B:26:0x006e, code lost: r0 = r0 + 1; r1 = ((r9.length - r2) - r8) - r0; */ /* JADX WARN: Code restructure failed: missing block: B:27:0x0073, code lost: if (r1 <= 0) goto L32; */ /* JADX WARN: Code restructure failed: missing block: B:28:0x0075, code lost: r8 = new byte[r1]; java.lang.System.arraycopy(r9, r0, r8, 0, r1); */ /* JADX WARN: Code restructure failed: missing block: B:29:0x007a, code lost: return r8; */ /* JADX WARN: Code restructure failed: missing block: B:31:0x0080, code lost: throw new java.lang.NumberFormatException("Could not get M1"); */ /* JADX WARN: Code restructure failed: missing block: B:33:0x0081, code lost: r0 = new java.lang.StringBuilder("Could not get M1, first byte indicates partial recovery not enabled: "); r0.append(java.lang.Integer.toHexString(r9[0])); */ /* JADX WARN: Code restructure failed: missing block: B:34:0x009a, code lost: throw new java.lang.NumberFormatException(r0.toString()); */ /* JADX WARN: Code restructure failed: missing block: B:36:0x00a0, code lost: throw new java.lang.NumberFormatException("Could not get M1"); */ /* JADX WARN: Code restructure failed: missing block: B:38:0x0047, code lost: if (((r9[r9.length - 1] & com.google.common.primitives.UnsignedBytes.MAX_VALUE) ^ 204) != 0) goto L38; */ /* JADX WARN: Code restructure failed: missing block: B:39:0x0049, code lost: r2 = 2; */ /* JADX WARN: Code restructure failed: missing block: B:41:0x00a8, code lost: throw new java.lang.NumberFormatException("Not an ISO 9796-2 scheme 2 signature trailer"); */ /* JADX WARN: Code restructure failed: missing block: B:43:0x00b0, code lost: throw new java.lang.NumberFormatException("Could not get M1, malformed trailer"); */ /* JADX WARN: Code restructure failed: missing block: B:44:0x0015, code lost: if (r9 != null) goto L8; */ /* JADX WARN: Code restructure failed: missing block: B:4:0x0012, code lost: if (r9 != null) goto L8; */ /* JADX WARN: Code restructure failed: missing block: B:9:0x0018, code lost: if (r9.length <= 0) goto L42; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static byte[] recoverMessage(int r8, byte[] r9) { /* Method dump skipped, instructions count: 185 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: org.jmrtd.Util.recoverMessage(int, byte[]):byte[]"); } public static byte[] getRawECDSASignature(byte[] bArr, int i) throws IOException { int i2 = 2 % 2; ASN1InputStream aSN1InputStream = new ASN1InputStream(bArr); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { Enumeration objects = ((ASN1Sequence) aSN1InputStream.readObject()).getObjects(); while (objects.hasMoreElements()) { int i3 = f + 101; a = i3 % 128; if (i3 % 2 != 0) { byteArrayOutputStream.write(alignKeyDataToSize(((ASN1Integer) objects.nextElement()).getValue().toByteArray(), i)); throw null; } byteArrayOutputStream.write(alignKeyDataToSize(((ASN1Integer) objects.nextElement()).getValue().toByteArray(), i)); } byteArrayOutputStream.flush(); byte[] byteArray = byteArrayOutputStream.toByteArray(); aSN1InputStream.close(); byteArrayOutputStream.close(); int i4 = f + 23; a = i4 % 128; if (i4 % 2 == 0) { return byteArray; } throw null; } catch (Throwable th) { aSN1InputStream.close(); byteArrayOutputStream.close(); throw th; } } public static byte[] alignKeyDataToSize(byte[] bArr, int i) { int i2 = 2 % 2; int i3 = f + 87; a = i3 % 128; Object obj = null; if (i3 % 2 == 0) { byte[] bArr2 = new byte[i]; int length = bArr.length < i ? bArr.length : i; System.arraycopy(bArr, bArr.length - length, bArr2, i - length, length); int i4 = a + 107; f = i4 % 128; if (i4 % 2 != 0) { return bArr2; } obj.hashCode(); throw null; } byte[] bArr3 = new byte[i]; int length2 = bArr.length; throw null; } public static byte[] i2os(BigInteger bigInteger, int i) { int i2 = 2 % 2; BigInteger valueOf = BigInteger.valueOf(256L); byte[] bArr = new byte[i]; int i3 = f + 51; a = i3 % 128; if (i3 % 2 != 0) { int i4 = 3 / 2; } for (int i5 = 0; i5 < i; i5++) { BigInteger mod = bigInteger.mod(valueOf); bigInteger = bigInteger.divide(valueOf); bArr[(i - 1) - i5] = (byte) mod.intValue(); } int i6 = a + 59; f = i6 % 128; if (i6 % 2 != 0) { return bArr; } throw null; } public static byte[] i2os(BigInteger bigInteger) { int i = 2 % 2; int length = bigInteger.toString(16).length(); if (length % 2 != 0) { int i2 = a + 71; f = i2 % 128; int i3 = i2 % 2; length++; } byte[] i2os = i2os(bigInteger, length / 2); int i4 = f + 9; a = i4 % 128; int i5 = i4 % 2; return i2os; } public static BigInteger os2i(byte[] bArr) { int i = 2 % 2; int i2 = a + 101; int i3 = i2 % 128; f = i3; int i4 = i2 % 2; if (bArr == null) { throw new IllegalArgumentException(); } int i5 = i3 + 107; a = i5 % 128; int i6 = i5 % 2; return os2i(bArr, 0, bArr.length); } public static BigInteger os2i(byte[] bArr, int i, int i2) { int i3 = 2 % 2; int i4 = a + 87; f = i4 % 128; if (i4 % 2 == 0) { Object obj = null; obj.hashCode(); throw null; } if (bArr == null) { throw new IllegalArgumentException(); } BigInteger bigInteger = BigInteger.ZERO; BigInteger valueOf = BigInteger.valueOf(256L); int i5 = i; while (i5 < i + i2) { int i6 = f + 45; a = i6 % 128; if (i6 % 2 != 0) { bigInteger = bigInteger.multiply(valueOf).add(BigInteger.valueOf(bArr[i5] & 23527)); i5 += 49; } else { bigInteger = bigInteger.multiply(valueOf).add(BigInteger.valueOf(bArr[i5] & UnsignedBytes.MAX_VALUE)); i5++; } } return bigInteger; } public static BigInteger os2fe(byte[] bArr, BigInteger bigInteger) { int i = 2 % 2; int i2 = a + 29; f = i2 % 128; int i3 = i2 % 2; BigInteger os2i = os2i(bArr); if (i3 != 0) { return os2i.mod(bigInteger); } os2i.mod(bigInteger); throw null; } /* JADX WARN: Code restructure failed: missing block: B:25:0x002b, code lost: r5 = r5.split("WITH")[0]; */ /* JADX WARN: Code restructure failed: missing block: B:27:0x0029, code lost: if (r5.contains("WITH") != false) goto L11; */ /* JADX WARN: Code restructure failed: missing block: B:6:0x001e, code lost: if (r5.contains("WITH") != false) goto L11; */ /* JADX WARN: Code restructure failed: missing block: B:7:0x0032, code lost: r5 = null; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static java.lang.String inferDigestAlgorithmFromSignatureAlgorithm(java.lang.String r5) { /* r0 = 2 int r1 = r0 % r0 if (r5 == 0) goto L6f int r1 = org.jmrtd.Util.f int r1 = r1 + 79 int r2 = r1 % 128 org.jmrtd.Util.a = r2 int r1 = r1 % r0 r2 = 0 java.lang.String r3 = "WITH" if (r1 == 0) goto L21 java.lang.String r5 = r5.toUpperCase() boolean r1 = r5.contains(r3) r4 = 31 int r4 = r4 / r2 if (r1 == 0) goto L32 goto L2b L21: java.lang.String r5 = r5.toUpperCase() boolean r1 = r5.contains(r3) if (r1 == 0) goto L32 L2b: java.lang.String[] r5 = r5.split(r3) r5 = r5[r2] goto L33 L32: r5 = 0 L33: java.lang.String r1 = "SHA1" boolean r1 = r1.equalsIgnoreCase(r5) if (r1 == 0) goto L46 int r5 = org.jmrtd.Util.a int r5 = r5 + 75 int r1 = r5 % 128 org.jmrtd.Util.f = r1 int r5 = r5 % r0 java.lang.String r5 = "SHA-1" L46: java.lang.String r0 = "SHA224" boolean r0 = r0.equalsIgnoreCase(r5) if (r0 == 0) goto L50 java.lang.String r5 = "SHA-224" L50: java.lang.String r0 = "SHA256" boolean r0 = r0.equalsIgnoreCase(r5) if (r0 == 0) goto L5a java.lang.String r5 = "SHA-256" L5a: java.lang.String r0 = "SHA384" boolean r0 = r0.equalsIgnoreCase(r5) if (r0 == 0) goto L64 java.lang.String r5 = "SHA-384" L64: java.lang.String r0 = "SHA512" boolean r0 = r0.equalsIgnoreCase(r5) if (r0 == 0) goto L6e java.lang.String r5 = "SHA-512" L6e: return r5 L6f: java.lang.IllegalArgumentException r5 = new java.lang.IllegalArgumentException r5.() throw r5 */ throw new UnsupportedOperationException("Method not decompiled: org.jmrtd.Util.inferDigestAlgorithmFromSignatureAlgorithm(java.lang.String):java.lang.String"); } /* JADX WARN: Code restructure failed: missing block: B:27:0x0072, code lost: if (r6 == 256) goto L28; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static java.lang.String inferDigestAlgorithmFromCipherAlgorithmForKeyDerivation(java.lang.String r5, int r6) { /* r0 = 2 int r1 = r0 % r0 if (r5 == 0) goto L93 java.lang.String r1 = "DESede" boolean r1 = r1.equals(r5) java.lang.String r2 = "SHA-1" if (r1 != 0) goto L92 java.lang.String r1 = "AES-128" boolean r1 = r1.equals(r5) if (r1 != 0) goto L92 java.lang.String r1 = "AES" boolean r3 = r1.equals(r5) r4 = 1 if (r3 == 0) goto L3b r3 = 128(0x80, float:1.8E-43) if (r6 != r3) goto L3b int r5 = org.jmrtd.Util.a int r5 = r5 + r4 int r6 = r5 % 128 org.jmrtd.Util.f = r6 int r5 = r5 % r0 if (r5 == 0) goto L36 int r6 = r6 + 39 int r5 = r6 % 128 org.jmrtd.Util.a = r5 int r6 = r6 % r0 return r2 L36: r5 = 0 r5.hashCode() throw r5 L3b: java.lang.String r2 = "AES-256" boolean r2 = r2.equals(r5) java.lang.String r3 = "SHA-256" if (r2 != 0) goto L91 java.lang.String r2 = "AES-192" boolean r2 = r2.equals(r5) if (r2 == r4) goto L91 int r2 = org.jmrtd.Util.a int r2 = r2 + 53 int r4 = r2 % 128 org.jmrtd.Util.f = r4 int r2 = r2 % r0 boolean r1 = r1.equals(r5) if (r1 == 0) goto L75 int r1 = org.jmrtd.Util.f int r1 = r1 + 13 int r2 = r1 % 128 org.jmrtd.Util.a = r2 int r1 = r1 % r0 r1 = 192(0xc0, float:2.69E-43) if (r6 == r1) goto L74 int r2 = r2 + 109 int r1 = r2 % 128 org.jmrtd.Util.f = r1 int r2 = r2 % r0 r0 = 256(0x100, float:3.59E-43) if (r6 != r0) goto L75 L74: return r3 L75: java.lang.IllegalArgumentException r0 = new java.lang.IllegalArgumentException java.lang.StringBuilder r1 = new java.lang.StringBuilder java.lang.String r2 = "Unsupported cipher algorithm or key length \"" r1.(r2) r1.append(r5) java.lang.String r5 = "\", " r1.append(r5) r1.append(r6) java.lang.String r5 = r1.toString() r0.(r5) throw r0 L91: return r3 L92: return r2 L93: java.lang.IllegalArgumentException r5 = new java.lang.IllegalArgumentException r5.() throw r5 */ throw new UnsupportedOperationException("Method not decompiled: org.jmrtd.Util.inferDigestAlgorithmFromCipherAlgorithmForKeyDerivation(java.lang.String, int):java.lang.String"); } public static DHParameterSpec toExplicitDHParameterSpec(DHParameters dHParameters) { int i = 2 % 2; DHParameterSpec dHParameterSpec = new DHParameterSpec(dHParameters.getP(), dHParameters.getG(), dHParameters.getL()); int i2 = f + 25; a = i2 % 128; if (i2 % 2 == 0) { return dHParameterSpec; } Object obj = null; obj.hashCode(); throw null; } public static String getDetailedPublicKeyAlgorithm(PublicKey publicKey) { String curveName; int i = 2 % 2; int i2 = f; int i3 = i2 + 101; a = i3 % 128; if (i3 % 2 != 0) { throw null; } if (publicKey == null) { int i4 = i2 + 105; a = i4 % 128; if (i4 % 2 != 0) { Object[] objArr = new Object[1]; g(new char[]{54277, 13385, 26542, 22246}, 2 >>> Color.argb(1, 1, 0, 0), objArr); return ((String) objArr[0]).intern(); } Object[] objArr2 = new Object[1]; g(new char[]{54277, 13385, 26542, 22246}, Color.argb(0, 0, 0, 0) + 4, objArr2); return ((String) objArr2[0]).intern(); } String algorithm = publicKey.getAlgorithm(); if (publicKey instanceof RSAPublicKey) { int bitLength = ((RSAPublicKey) publicKey).getModulus().bitLength(); StringBuilder sb = new StringBuilder(); sb.append(algorithm); sb.append(" ["); sb.append(bitLength); sb.append(" bit]"); String obj = sb.toString(); int i5 = f + 79; a = i5 % 128; int i6 = i5 % 2; return obj; } if (!(publicKey instanceof ECPublicKey) || (curveName = getCurveName(((ECPublicKey) publicKey).getParams())) == null) { return algorithm; } StringBuilder sb2 = new StringBuilder(); sb2.append(algorithm); sb2.append(" ["); sb2.append(curveName); sb2.append("]"); return sb2.toString(); } public static String getDetailedPrivateKeyAlgorithm(PrivateKey privateKey) { int i = 2 % 2; if (privateKey == null) { int i2 = f + 23; a = i2 % 128; int i3 = i2 % 2; Object[] objArr = new Object[1]; g(new char[]{54277, 13385, 26542, 22246}, 4 - (ViewConfiguration.getFadingEdgeLength() >> 16), objArr); return ((String) objArr[0]).intern(); } String algorithm = privateKey.getAlgorithm(); if (privateKey instanceof RSAPrivateKey) { int bitLength = ((RSAPrivateKey) privateKey).getModulus().bitLength(); StringBuilder sb = new StringBuilder(); sb.append(algorithm); sb.append(" ["); sb.append(bitLength); sb.append(" bit]"); return sb.toString(); } if (true ^ (privateKey instanceof ECPrivateKey)) { return algorithm; } int i4 = f + 7; a = i4 % 128; int i5 = i4 % 2; String curveName = getCurveName(((ECPrivateKey) privateKey).getParams()); if (curveName == null) { return algorithm; } StringBuilder sb2 = new StringBuilder(); sb2.append(algorithm); sb2.append(" ["); sb2.append(curveName); sb2.append("]"); return sb2.toString(); } public static String getCurveName(ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = f + 25; a = i2 % 128; int i3 = i2 % 2; ECNamedCurveSpec namedCurveSpec = toNamedCurveSpec(eCParameterSpec); if (namedCurveSpec != null) { return namedCurveSpec.getName(); } int i4 = f + 23; int i5 = i4 % 128; a = i5; int i6 = i4 % 2; int i7 = i5 + 33; f = i7 % 128; int i8 = i7 % 2; return null; } public static ECParameterSpec toExplicitECParameterSpec(ECNamedCurveParameterSpec eCNamedCurveParameterSpec) { int i = 2 % 2; int i2 = f + 73; a = i2 % 128; int i3 = i2 % 2; ECParameterSpec explicitECParameterSpec = toExplicitECParameterSpec(toECNamedCurveSpec(eCNamedCurveParameterSpec)); if (i3 != 0) { int i4 = 32 / 0; } int i5 = f + 43; a = i5 % 128; int i6 = i5 % 2; return explicitECParameterSpec; } public static ECParameterSpec toExplicitECParameterSpec(ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = f + 113; a = i2 % 128; int i3 = i2 % 2; try { ECPoint generator = eCParameterSpec.getGenerator(); BigInteger order = eCParameterSpec.getOrder(); int cofactor = eCParameterSpec.getCofactor(); EllipticCurve curve = eCParameterSpec.getCurve(); BigInteger a2 = curve.getA(); BigInteger b2 = curve.getB(); ECField field = curve.getField(); if (field instanceof ECFieldFp) { ECParameterSpec eCParameterSpec2 = new ECParameterSpec(new EllipticCurve(new ECFieldFp(((ECFieldFp) field).getP()), a2, b2), generator, order, cofactor); int i4 = f + 49; a = i4 % 128; if (i4 % 2 == 0) { return eCParameterSpec2; } throw null; } if (field instanceof ECFieldF2m) { return new ECParameterSpec(new EllipticCurve(new ECFieldF2m(((ECFieldF2m) field).getM()), a2, b2), generator, order, cofactor); } LOGGER.warning("Could not make named EC param spec explicit"); return eCParameterSpec; } catch (Exception unused) { LOGGER.warning("Could not make named EC param spec explicit"); return eCParameterSpec; } } private static ECNamedCurveSpec toNamedCurveSpec(ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = f; int i3 = i2 + 25; a = i3 % 128; Object obj = null; if (i3 % 2 != 0) { obj.hashCode(); throw null; } if (eCParameterSpec == null) { return null; } if (eCParameterSpec instanceof ECNamedCurveSpec) { int i4 = i2 + 43; a = i4 % 128; int i5 = i4 % 2; return (ECNamedCurveSpec) eCParameterSpec; } ArrayList list = Collections.list(ECNamedCurveTable.getNames()); ArrayList arrayList = new ArrayList(); Iterator it = list.iterator(); while (it.hasNext()) { ECNamedCurveSpec eCNamedCurveSpec = toECNamedCurveSpec(ECNamedCurveTable.getParameterSpec((String) it.next())); if (eCNamedCurveSpec.getCurve().equals(eCParameterSpec.getCurve())) { int i6 = a + 81; f = i6 % 128; if (i6 % 2 == 0) { eCNamedCurveSpec.getGenerator().equals(eCParameterSpec.getGenerator()); throw null; } if (eCNamedCurveSpec.getGenerator().equals(eCParameterSpec.getGenerator()) && eCNamedCurveSpec.getOrder().equals(eCParameterSpec.getOrder()) && eCNamedCurveSpec.getCofactor() == eCParameterSpec.getCofactor()) { int i7 = f + 97; a = i7 % 128; int i8 = i7 % 2; arrayList.add(eCNamedCurveSpec); } } } if (arrayList.size() == 0) { return null; } if (arrayList.size() != 1) { return (ECNamedCurveSpec) arrayList.get(0); } int i9 = f + 59; a = i9 % 128; int i10 = i9 % 2; return (ECNamedCurveSpec) arrayList.get(0); } public static ECNamedCurveSpec toECNamedCurveSpec(ECNamedCurveParameterSpec eCNamedCurveParameterSpec) { int i = 2 % 2; ECNamedCurveSpec eCNamedCurveSpec = new ECNamedCurveSpec(eCNamedCurveParameterSpec.getName(), eCNamedCurveParameterSpec.getCurve(), eCNamedCurveParameterSpec.getG(), eCNamedCurveParameterSpec.getN(), eCNamedCurveParameterSpec.getH(), eCNamedCurveParameterSpec.getSeed()); int i2 = a + 75; f = i2 % 128; if (i2 % 2 != 0) { return eCNamedCurveSpec; } throw null; } public static SubjectPublicKeyInfo toSubjectPublicKeyInfo(PublicKey publicKey) { int i = 2 % 2; Object obj = null; try { String algorithm = publicKey.getAlgorithm(); if (!"EC".equals(algorithm) && !"ECDH".equals(algorithm) && !(publicKey instanceof ECPublicKey)) { if (!"DH".equals(algorithm) && !(publicKey instanceof DHPublicKey)) { StringBuilder sb = new StringBuilder("Unrecognized key type, found "); sb.append(publicKey.getAlgorithm()); sb.append(", should be DH or ECDH"); throw new IllegalArgumentException(sb.toString()); } DHPublicKey dHPublicKey = (DHPublicKey) publicKey; DHParameterSpec params = dHPublicKey.getParams(); return new SubjectPublicKeyInfo(new AlgorithmIdentifier(EACObjectIdentifiers.id_PK_DH, new DHParameter(params.getP(), params.getG(), params.getL()).toASN1Primitive()), new ASN1Integer(dHPublicKey.getY())); } ASN1InputStream aSN1InputStream = new ASN1InputStream(publicKey.getEncoded()); SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo((ASN1Sequence) aSN1InputStream.readObject()); aSN1InputStream.close(); AlgorithmIdentifier algorithm2 = subjectPublicKeyInfo.getAlgorithm(); String id = algorithm2.getAlgorithm().getId(); if (!SecurityInfo.ID_EC_PUBLIC_KEY.equals(id)) { StringBuilder sb2 = new StringBuilder("Was expecting id-ecPublicKey ("); sb2.append(SecurityInfo.ID_EC_PUBLIC_KEY_TYPE); sb2.append("), found "); sb2.append(id); throw new IllegalStateException(sb2.toString()); } int i2 = f + 23; a = i2 % 128; if (i2 % 2 == 0) { ASN1Primitive aSN1Primitive = algorithm2.getParameters().toASN1Primitive(); if (!(aSN1Primitive instanceof ASN1ObjectIdentifier)) { return subjectPublicKeyInfo; } ASN1ObjectIdentifier aSN1ObjectIdentifier = (ASN1ObjectIdentifier) aSN1Primitive; X9ECParameters byOID = X962NamedCurves.getByOID(aSN1ObjectIdentifier); if (byOID == null) { StringBuilder sb3 = new StringBuilder("Could not find X9.62 named curve for OID "); sb3.append(aSN1ObjectIdentifier.getId()); throw new IllegalStateException(sb3.toString()); } org.bouncycastle.math.ec.ECPoint g = byOID.getG(); X9ECParameters x9ECParameters = new X9ECParameters(byOID.getCurve(), g.getCurve().createPoint(g.getX().toBigInteger(), g.getY().toBigInteger(), false), byOID.getN(), byOID.getH(), byOID.getSeed()); if (!(publicKey instanceof org.bouncycastle.jce.interfaces.ECPublicKey)) { int i3 = a + 27; f = i3 % 128; if (i3 % 2 != 0) { return subjectPublicKeyInfo; } obj.hashCode(); throw null; } return new SubjectPublicKeyInfo(new AlgorithmIdentifier(subjectPublicKeyInfo.getAlgorithm().getAlgorithm(), x9ECParameters.toASN1Primitive()), ((org.bouncycastle.jce.interfaces.ECPublicKey) publicKey).getQ().getEncoded()); } boolean z = algorithm2.getParameters().toASN1Primitive() instanceof ASN1ObjectIdentifier; obj.hashCode(); throw null; } catch (Exception e2) { Logger logger = LOGGER; StringBuilder sb4 = new StringBuilder("Exception: "); sb4.append(e2.getMessage()); logger.severe(sb4.toString()); return null; } } public static PublicKey toPublicKey(SubjectPublicKeyInfo subjectPublicKeyInfo) { int i = 2 % 2; try { try { X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(subjectPublicKeyInfo.getEncoded(ASN1Encoding.DER)); try { PublicKey generatePublic = KeyFactory.getInstance("DH").generatePublic(x509EncodedKeySpec); int i2 = f + 85; a = i2 % 128; if (i2 % 2 == 0) { return generatePublic; } throw null; } catch (GeneralSecurityException unused) { return KeyFactory.getInstance("EC", BC_PROVIDER).generatePublic(x509EncodedKeySpec); } } catch (GeneralSecurityException e2) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e2.getMessage()); logger.severe(sb.toString()); return null; } } catch (Exception e3) { Logger logger2 = LOGGER; StringBuilder sb2 = new StringBuilder("Exception: "); sb2.append(e3.getMessage()); logger2.severe(sb2.toString()); return null; } } public static PublicKey reconstructPublicKey(PublicKey publicKey) { int i = 2 % 2; int i2 = f; int i3 = i2 + 5; a = i3 % 128; int i4 = i3 % 2; if (!(publicKey instanceof ECPublicKey)) { int i5 = i2 + 93; a = i5 % 128; int i6 = i5 % 2; return publicKey; } try { ECPublicKey eCPublicKey = (ECPublicKey) publicKey; ECPoint w = eCPublicKey.getW(); ECParameterSpec explicitECParameterSpec = toExplicitECParameterSpec(eCPublicKey.getParams()); if (explicitECParameterSpec != null) { PublicKey generatePublic = KeyFactory.getInstance("EC", BC_PROVIDER).generatePublic(new ECPublicKeySpec(w, explicitECParameterSpec)); int i7 = f + 7; a = i7 % 128; int i8 = i7 % 2; return generatePublic; } int i9 = a + 101; f = i9 % 128; if (i9 % 2 != 0) { return publicKey; } Object obj = null; obj.hashCode(); throw null; } catch (Exception unused) { LOGGER.warning("Could not make public key param spec explicit"); return publicKey; } } public static byte[] encodePublicKeyDataObject(String str, PublicKey publicKey) throws InvalidKeyException { int i = 2 % 2; int i2 = a + 41; f = i2 % 128; byte[] encodePublicKeyDataObject = encodePublicKeyDataObject(str, publicKey, i2 % 2 != 0); int i3 = f + 57; a = i3 % 128; int i4 = i3 % 2; return encodePublicKeyDataObject; } public static byte[] encodePublicKeyDataObject(String str, PublicKey publicKey, boolean z) throws InvalidKeyException { int i = 2 % 2; ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); TLVOutputStream tLVOutputStream = new TLVOutputStream(byteArrayOutputStream); try { tLVOutputStream.d(32585); if (publicKey instanceof DHPublicKey) { DHPublicKey dHPublicKey = (DHPublicKey) publicKey; DHParameterSpec params = dHPublicKey.getParams(); BigInteger p = params.getP(); int l = params.getL(); BigInteger g = params.getG(); BigInteger y = dHPublicKey.getY(); tLVOutputStream.write(new ASN1ObjectIdentifier(str).getEncoded()); if (!z) { int i2 = f + 7; a = i2 % 128; int i3 = i2 % 2; tLVOutputStream.d(129); tLVOutputStream.d(i2os(p)); tLVOutputStream.d(ISO781611.BIOMETRIC_SUBTYPE_TAG); tLVOutputStream.d(i2os(BigInteger.valueOf(l))); tLVOutputStream.d(ISO781611.CREATION_DATE_AND_TIME_TAG); tLVOutputStream.d(i2os(g)); } tLVOutputStream.d(CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA); tLVOutputStream.d(i2os(y)); } else { if (!(publicKey instanceof ECPublicKey)) { StringBuilder sb = new StringBuilder("Unsupported public key: "); sb.append(publicKey.getClass().getCanonicalName()); throw new InvalidKeyException(sb.toString()); } ECPublicKey eCPublicKey = (ECPublicKey) publicKey; ECParameterSpec params2 = eCPublicKey.getParams(); BigInteger prime = getPrime(params2); EllipticCurve curve = params2.getCurve(); BigInteger a2 = curve.getA(); BigInteger b2 = curve.getB(); ECPoint generator = params2.getGenerator(); BigInteger order = params2.getOrder(); int cofactor = params2.getCofactor(); ECPoint w = eCPublicKey.getW(); tLVOutputStream.write(new ASN1ObjectIdentifier(str).getEncoded()); if (!z) { int i4 = a + 95; f = i4 % 128; int i5 = i4 % 2; tLVOutputStream.d(129); tLVOutputStream.d(i2os(prime)); tLVOutputStream.d(ISO781611.BIOMETRIC_SUBTYPE_TAG); tLVOutputStream.d(i2os(a2)); tLVOutputStream.d(ISO781611.CREATION_DATE_AND_TIME_TAG); tLVOutputStream.d(i2os(b2)); BigInteger affineX = generator.getAffineX(); BigInteger affineY = generator.getAffineY(); tLVOutputStream.d(CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA); tLVOutputStream.write(i2os(affineX)); tLVOutputStream.write(i2os(affineY)); tLVOutputStream.c(); tLVOutputStream.d(133); tLVOutputStream.d(i2os(order)); } tLVOutputStream.d(134); tLVOutputStream.d(ecPoint2OS(w)); if (!z) { tLVOutputStream.d(135); tLVOutputStream.d(i2os(BigInteger.valueOf(cofactor))); } } tLVOutputStream.c(); tLVOutputStream.flush(); tLVOutputStream.close(); return byteArrayOutputStream.toByteArray(); } catch (IOException e2) { Logger logger = LOGGER; StringBuilder sb2 = new StringBuilder("Exception: "); sb2.append(e2.getMessage()); logger.severe(sb2.toString()); throw new IllegalStateException("Error in encoding public key"); } } public static byte[] encodePublicKeyForSmartCard(PublicKey publicKey) throws InvalidKeyException { int i = 2 % 2; if (publicKey == null) { throw new IllegalArgumentException("Cannot encode null public key"); } if (publicKey instanceof ECPublicKey) { ECPublicKey eCPublicKey = (ECPublicKey) publicKey; try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byteArrayOutputStream.write(ecPoint2OS(eCPublicKey.getW())); byte[] byteArray = byteArrayOutputStream.toByteArray(); byteArrayOutputStream.close(); return byteArray; } catch (IOException e2) { StringBuilder sb = new StringBuilder("Internal error writing to memory: "); sb.append(e2.getMessage()); throw new IllegalStateException(sb.toString()); } } if (!(publicKey instanceof DHPublicKey)) { StringBuilder sb2 = new StringBuilder("Unsupported public key: "); sb2.append(publicKey.getClass().getCanonicalName()); throw new InvalidKeyException(sb2.toString()); } int i2 = f + 115; a = i2 % 128; if (i2 % 2 != 0) { i2os(((DHPublicKey) publicKey).getY()); Object obj = null; obj.hashCode(); throw null; } byte[] i2os = i2os(((DHPublicKey) publicKey).getY()); int i3 = f + 81; a = i3 % 128; int i4 = i3 % 2; return i2os; } public static ECPoint os2ECPoint(byte[] bArr) { int i = 2 % 2; try { DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(bArr)); if (dataInputStream.read() != 4) { throw new IllegalArgumentException("Expected encoded ECPoint to start with 0x04"); } int length = (bArr.length - 1) / 2; byte[] bArr2 = new byte[length]; byte[] bArr3 = new byte[length]; dataInputStream.readFully(bArr2); dataInputStream.readFully(bArr3); dataInputStream.close(); ECPoint eCPoint = new ECPoint(os2i(bArr2), os2i(bArr3)); int i2 = a + 47; f = i2 % 128; if (i2 % 2 == 0) { int i3 = 83 / 0; } return eCPoint; } catch (IOException e2) { LOGGER.log(Level.SEVERE, "Exception", (Throwable) e2); throw new IllegalArgumentException(e2.getMessage()); } } public static byte[] ecPoint2OS(ECPoint eCPoint) { int i = 2 % 2; ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); BigInteger affineX = eCPoint.getAffineX(); BigInteger affineY = eCPoint.getAffineY(); try { byteArrayOutputStream.write(4); byteArrayOutputStream.write(i2os(affineX)); byteArrayOutputStream.write(i2os(affineY)); byteArrayOutputStream.close(); byte[] byteArray = byteArrayOutputStream.toByteArray(); int i2 = f + 109; a = i2 % 128; int i3 = i2 % 2; return byteArray; } catch (IOException e2) { throw new IllegalStateException(e2.getMessage()); } } /* JADX WARN: Code restructure failed: missing block: B:10:0x003e, code lost: r1 = new java.io.DataInputStream(new java.io.ByteArrayInputStream(r5)); */ /* JADX WARN: Code restructure failed: missing block: B:11:0x004d, code lost: if (r1.read() != 4) goto L27; */ /* JADX WARN: Code restructure failed: missing block: B:12:0x004f, code lost: r5 = new byte[r5.length - 1]; r1.readFully(r5); r1.close(); r6 = (javax.crypto.spec.DHParameterSpec) r6; r5 = java.security.KeyFactory.getInstance("DH").generatePublic(new javax.crypto.spec.DHPublicKeySpec(os2i(r5), r6.getP(), r6.getG())); */ /* JADX WARN: Code restructure failed: missing block: B:13:0x0077, code lost: r6 = org.jmrtd.Util.f + 123; org.jmrtd.Util.a = r6 % 128; */ /* JADX WARN: Code restructure failed: missing block: B:14:0x0080, code lost: if ((r6 % 2) != 0) goto L25; */ /* JADX WARN: Code restructure failed: missing block: B:15:0x0082, code lost: return r5; */ /* JADX WARN: Code restructure failed: missing block: B:18:0x0084, code lost: throw null; */ /* JADX WARN: Code restructure failed: missing block: B:20:0x008c, code lost: throw new java.lang.IllegalArgumentException("Expected encoded public key to start with 0x04"); */ /* JADX WARN: Code restructure failed: missing block: B:21:0x008d, code lost: r0 = new java.lang.StringBuilder("Expected ECParameterSpec or DHParameterSpec, found "); r0.append(r6.getClass().getCanonicalName()); */ /* JADX WARN: Code restructure failed: missing block: B:22:0x00a8, code lost: throw new java.lang.IllegalArgumentException(r0.toString()); */ /* JADX WARN: Code restructure failed: missing block: B:24:0x0034, code lost: return java.security.KeyFactory.getInstance("EC").generatePublic(new java.security.spec.ECPublicKeySpec(os2ECPoint(r5), (java.security.spec.ECParameterSpec) r6)); */ /* JADX WARN: Code restructure failed: missing block: B:26:0x001d, code lost: if ((r6 instanceof java.security.spec.ECParameterSpec) != false) goto L11; */ /* JADX WARN: Code restructure failed: missing block: B:7:0x0018, code lost: if ((r6 instanceof java.security.spec.ECParameterSpec) != false) goto L11; */ /* JADX WARN: Code restructure failed: missing block: B:9:0x003c, code lost: if ((r6 instanceof javax.crypto.spec.DHParameterSpec) == false) goto L29; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static java.security.PublicKey decodePublicKeyFromSmartCard(byte[] r5, java.security.spec.AlgorithmParameterSpec r6) { /* Method dump skipped, instructions count: 239 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: org.jmrtd.Util.decodePublicKeyFromSmartCard(byte[], java.security.spec.AlgorithmParameterSpec):java.security.PublicKey"); } public static String inferProtocolIdentifier(PublicKey publicKey) { int i = 2 % 2; String algorithm = publicKey.getAlgorithm(); if (!"EC".equals(algorithm)) { int i2 = f + 57; a = i2 % 128; int i3 = i2 % 2; if (!"ECDH".equals(algorithm)) { if (!"DH".equals(algorithm)) { throw new IllegalArgumentException("Wrong key type. Was expecting ECDH or DH public key."); } String str = SecurityInfo.ID_PK_DH; int i4 = a + 123; f = i4 % 128; if (i4 % 2 == 0) { int i5 = 39 / 0; } return str; } } return SecurityInfo.ID_PK_ECDH; } public static AlgorithmParameterSpec mapNonceGM(byte[] bArr, byte[] bArr2, AlgorithmParameterSpec algorithmParameterSpec) { int i = 2 % 2; int i2 = f; int i3 = i2 + 19; a = i3 % 128; int i4 = i3 % 2; if (algorithmParameterSpec == null) { throw new IllegalArgumentException("Unsupported parameters for mapping nonce"); } if (algorithmParameterSpec instanceof ECParameterSpec) { ECParameterSpec eCParameterSpec = (ECParameterSpec) algorithmParameterSpec; BigInteger os2i = os2i(bArr2); return mapNonceGMWithECDH(os2i(bArr), new ECPoint(os2i, computeAffineY(os2i, eCParameterSpec)), eCParameterSpec); } if (algorithmParameterSpec instanceof DHParameterSpec) { int i5 = i2 + 93; a = i5 % 128; if (i5 % 2 != 0) { DHParameterSpec mapNonceGMWithDH = mapNonceGMWithDH(os2i(bArr), os2i(bArr2), (DHParameterSpec) algorithmParameterSpec); int i6 = 20 / 0; return mapNonceGMWithDH; } return mapNonceGMWithDH(os2i(bArr), os2i(bArr2), (DHParameterSpec) algorithmParameterSpec); } StringBuilder sb = new StringBuilder("Unsupported parameters for mapping nonce, expected ECParameterSpec or DHParameterSpec, found "); sb.append(algorithmParameterSpec.getClass().getCanonicalName()); throw new IllegalArgumentException(sb.toString()); } public static ECParameterSpec mapNonceGMWithECDH(BigInteger bigInteger, ECPoint eCPoint, ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = f + 91; a = i2 % 128; int i3 = i2 % 2; ECPoint generator = eCParameterSpec.getGenerator(); EllipticCurve curve = eCParameterSpec.getCurve(); BigInteger a2 = curve.getA(); BigInteger b2 = curve.getB(); BigInteger p = ((ECFieldFp) curve.getField()).getP(); BigInteger order = eCParameterSpec.getOrder(); int cofactor = eCParameterSpec.getCofactor(); ECPoint add = add(multiply(bigInteger, generator, eCParameterSpec), eCPoint, eCParameterSpec); if (!toBouncyCastleECPoint(add, eCParameterSpec).isValid()) { int i4 = a + 125; f = i4 % 128; if (i4 % 2 == 0) { LOGGER.info("ephemeralGenerator is not a valid point"); Object obj = null; obj.hashCode(); throw null; } LOGGER.info("ephemeralGenerator is not a valid point"); int i5 = f + 57; a = i5 % 128; int i6 = i5 % 2; } return new ECParameterSpec(new EllipticCurve(new ECFieldFp(p), a2, b2), add, order, cofactor); } public static DHParameterSpec mapNonceGMWithDH(BigInteger bigInteger, BigInteger bigInteger2, DHParameterSpec dHParameterSpec) { int i = 2 % 2; BigInteger p = dHParameterSpec.getP(); DHParameterSpec dHParameterSpec2 = new DHParameterSpec(p, dHParameterSpec.getG().modPow(bigInteger, p).multiply(bigInteger2).mod(p), dHParameterSpec.getL()); int i2 = f + 57; a = i2 % 128; if (i2 % 2 == 0) { return dHParameterSpec2; } throw null; } private static ECPoint add(ECPoint eCPoint, ECPoint eCPoint2, ECParameterSpec eCParameterSpec) { ECPoint fromBouncyCastleECPoint; int i = 2 % 2; int i2 = f + 15; a = i2 % 128; if (i2 % 2 != 0) { fromBouncyCastleECPoint = fromBouncyCastleECPoint(toBouncyCastleECPoint(eCPoint, eCParameterSpec).add(toBouncyCastleECPoint(eCPoint2, eCParameterSpec))); int i3 = 72 / 0; } else { fromBouncyCastleECPoint = fromBouncyCastleECPoint(toBouncyCastleECPoint(eCPoint, eCParameterSpec).add(toBouncyCastleECPoint(eCPoint2, eCParameterSpec))); } int i4 = f + 1; a = i4 % 128; int i5 = i4 % 2; return fromBouncyCastleECPoint; } public static ECPoint multiply(BigInteger bigInteger, ECPoint eCPoint, ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = f + 37; a = i2 % 128; if (i2 % 2 != 0) { ECPoint fromBouncyCastleECPoint = fromBouncyCastleECPoint(toBouncyCastleECPoint(eCPoint, eCParameterSpec).multiply(bigInteger)); int i3 = 13 / 0; return fromBouncyCastleECPoint; } return fromBouncyCastleECPoint(toBouncyCastleECPoint(eCPoint, eCParameterSpec).multiply(bigInteger)); } private static byte[] getBytes(String str) { int i = 2 % 2; int i2 = a + 19; f = i2 % 128; int i3 = i2 % 2; byte[] bytes = str.getBytes(); try { bytes = str.getBytes("UTF-8"); int i4 = f + 37; a = i4 % 128; int i5 = i4 % 2; } catch (UnsupportedEncodingException e2) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e2.getMessage()); logger.severe(sb.toString()); } return bytes; } public static BigInteger getPrime(AlgorithmParameterSpec algorithmParameterSpec) { int i = 2 % 2; int i2 = f; int i3 = i2 + 53; a = i3 % 128; if (i3 % 2 != 0) { throw null; } if (algorithmParameterSpec == null) { throw new IllegalArgumentException("Parameters null"); } int i4 = i2 + 5; a = i4 % 128; int i5 = i4 % 2; if (algorithmParameterSpec instanceof DHParameterSpec) { BigInteger p = ((DHParameterSpec) algorithmParameterSpec).getP(); int i6 = a + 93; f = i6 % 128; if (i6 % 2 == 0) { int i7 = 69 / 0; } return p; } if (!(algorithmParameterSpec instanceof ECParameterSpec)) { StringBuilder sb = new StringBuilder("Unsupported agreement algorithm, was expecting DHParameterSpec or ECParameterSpec, found "); sb.append(algorithmParameterSpec.getClass().getCanonicalName()); throw new IllegalArgumentException(sb.toString()); } int i8 = i2 + 23; a = i8 % 128; int i9 = i8 % 2; ECField field = ((ECParameterSpec) algorithmParameterSpec).getCurve().getField(); if (!(field instanceof ECFieldFp)) { StringBuilder sb2 = new StringBuilder("Was expecting prime field of type ECFieldFp, found "); sb2.append(field.getClass().getCanonicalName()); throw new IllegalStateException(sb2.toString()); } int i10 = a + 79; f = i10 % 128; if (i10 % 2 != 0) { return ((ECFieldFp) field).getP(); } int i11 = 0 / 0; return ((ECFieldFp) field).getP(); } public static byte[] wrapDO(byte b2, byte[] bArr) { int i = 2 % 2; int i2 = f; int i3 = i2 + 57; a = i3 % 128; int i4 = i3 % 2; if (bArr == null) { throw new IllegalArgumentException("Data to wrap is null"); } int i5 = i2 + 65; a = i5 % 128; if (i5 % 2 != 0) { byte[] bArr2 = new byte[bArr.length / 3]; bArr2[1] = b2; bArr2[1] = (byte) bArr.length; System.arraycopy(bArr, 0, bArr2, 4, bArr.length); return bArr2; } byte[] bArr3 = new byte[bArr.length + 2]; bArr3[0] = b2; bArr3[1] = (byte) bArr.length; System.arraycopy(bArr, 0, bArr3, 2, bArr.length); return bArr3; } public static byte[] unwrapDO(byte b2, byte[] bArr) { byte b3; int i = 2 % 2; int i2 = f + 15; int i3 = i2 % 128; a = i3; int i4 = i2 % 2; if (bArr == null || bArr.length < 2) { throw new IllegalArgumentException("Wrapped data is null or length < 2"); } int i5 = i3 + 71; f = i5 % 128; if (i5 % 2 != 0 ? (b3 = bArr[0]) != b2 : (b3 = bArr[1]) != b2) { StringBuilder sb = new StringBuilder("Expected tag "); sb.append(Integer.toHexString(b2)); sb.append(", found tag "); sb.append(Integer.toHexString(b3)); throw new IllegalArgumentException(sb.toString()); } int i6 = i3 + 77; f = i6 % 128; if (i6 % 2 == 0) { int length = bArr.length - 5; byte[] bArr2 = new byte[length]; System.arraycopy(bArr, 3, bArr2, 0, length); return bArr2; } int length2 = bArr.length - 2; byte[] bArr3 = new byte[length2]; System.arraycopy(bArr, 2, bArr3, 0, length2); return bArr3; } public static String inferKeyAgreementAlgorithm(PublicKey publicKey) { int i = 2 % 2; if (!(publicKey instanceof ECPublicKey)) { if (!(publicKey instanceof DHPublicKey)) { throw new IllegalArgumentException("Unsupported public key: ".concat(String.valueOf(publicKey))); } int i2 = a + 15; f = i2 % 128; if (i2 % 2 != 0) { return "DH"; } Object obj = null; obj.hashCode(); throw null; } int i3 = a + 15; int i4 = i3 % 128; f = i4; if (i3 % 2 == 0) { int i5 = 14 / 0; } int i6 = i4 + 65; a = i6 % 128; int i7 = i6 % 2; return "ECDH"; } public static BigInteger computeAffineY(BigInteger bigInteger, ECParameterSpec eCParameterSpec) { int i = 2 % 2; ECCurve bouncyCastleECCurve = toBouncyCastleECCurve(eCParameterSpec); ECFieldElement a2 = bouncyCastleECCurve.getA(); ECFieldElement b2 = bouncyCastleECCurve.getB(); ECFieldElement fromBigInteger = bouncyCastleECCurve.fromBigInteger(bigInteger); Logger logger = LOGGER; StringBuilder sb = new StringBuilder("DEBUG: x.bitLength = "); sb.append(fromBigInteger.bitLength()); logger.info(sb.toString()); ECFieldElement sqrt = fromBigInteger.multiply(fromBigInteger).add(a2).multiply(fromBigInteger).add(b2).sqrt(); StringBuilder sb2 = new StringBuilder("DEBUG: y.bitLength = "); sb2.append(sqrt.bitLength()); logger.info(sb2.toString()); BigInteger bigInteger2 = sqrt.toBigInteger(); int i2 = f + 61; a = i2 % 128; if (i2 % 2 == 0) { return bigInteger2; } Object obj = null; obj.hashCode(); throw null; } private static org.bouncycastle.math.ec.ECPoint toBouncyCastleECPoint(ECPoint eCPoint, ECParameterSpec eCParameterSpec) { ECCurve bouncyCastleECCurve; BigInteger affineX; BigInteger affineY; boolean z; int i = 2 % 2; int i2 = f + 65; a = i2 % 128; if (i2 % 2 != 0) { bouncyCastleECCurve = toBouncyCastleECCurve(eCParameterSpec); affineX = eCPoint.getAffineX(); affineY = eCPoint.getAffineY(); z = true; } else { bouncyCastleECCurve = toBouncyCastleECCurve(eCParameterSpec); affineX = eCPoint.getAffineX(); affineY = eCPoint.getAffineY(); z = false; } org.bouncycastle.math.ec.ECPoint createPoint = bouncyCastleECCurve.createPoint(affineX, affineY, z); int i3 = a + 115; f = i3 % 128; if (i3 % 2 != 0) { return createPoint; } throw null; } /* JADX WARN: Code restructure failed: missing block: B:10:0x0025, code lost: if (r3.isValid() == false) goto L9; */ /* JADX WARN: Code restructure failed: missing block: B:4:0x001a, code lost: if (r3.isValid() == false) goto L9; */ /* JADX WARN: Code restructure failed: missing block: B:8:0x0027, code lost: org.jmrtd.Util.LOGGER.warning("point not valid"); */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static java.security.spec.ECPoint fromBouncyCastleECPoint(org.bouncycastle.math.ec.ECPoint r3) { /* r0 = 2 int r1 = r0 % r0 int r1 = org.jmrtd.Util.f int r1 = r1 + 23 int r2 = r1 % 128 org.jmrtd.Util.a = r2 int r1 = r1 % r0 if (r1 == 0) goto L1d org.bouncycastle.math.ec.ECPoint r3 = r3.normalize() boolean r1 = r3.isValid() r2 = 42 int r2 = r2 / 0 if (r1 != 0) goto L2e goto L27 L1d: org.bouncycastle.math.ec.ECPoint r3 = r3.normalize() boolean r1 = r3.isValid() if (r1 != 0) goto L2e L27: java.util.logging.Logger r1 = org.jmrtd.Util.LOGGER java.lang.String r2 = "point not valid" r1.warning(r2) L2e: java.security.spec.ECPoint r1 = new java.security.spec.ECPoint org.bouncycastle.math.ec.ECFieldElement r2 = r3.getAffineXCoord() java.math.BigInteger r2 = r2.toBigInteger() org.bouncycastle.math.ec.ECFieldElement r3 = r3.getAffineYCoord() java.math.BigInteger r3 = r3.toBigInteger() r1.(r2, r3) int r3 = org.jmrtd.Util.a int r3 = r3 + 17 int r2 = r3 % 128 org.jmrtd.Util.f = r2 int r3 = r3 % r0 return r1 */ throw new UnsupportedOperationException("Method not decompiled: org.jmrtd.Util.fromBouncyCastleECPoint(org.bouncycastle.math.ec.ECPoint):java.security.spec.ECPoint"); } public static boolean isValid(ECPoint eCPoint, ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = a + 5; f = i2 % 128; int i3 = i2 % 2; boolean isValid = toBouncyCastleECPoint(eCPoint, eCParameterSpec).isValid(); int i4 = a + 17; f = i4 % 128; if (i4 % 2 != 0) { return isValid; } Object obj = null; obj.hashCode(); throw null; } public static ECPoint normalize(ECPoint eCPoint, ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = f + 65; a = i2 % 128; int i3 = i2 % 2; ECPoint fromBouncyCastleECPoint = fromBouncyCastleECPoint(toBouncyCastleECPoint(eCPoint, eCParameterSpec).normalize()); int i4 = a + 117; f = i4 % 128; int i5 = i4 % 2; return fromBouncyCastleECPoint; } private static ECCurve toBouncyCastleECCurve(ECParameterSpec eCParameterSpec) { int i = 2 % 2; int i2 = f + 1; a = i2 % 128; int i3 = i2 % 2; EllipticCurve curve = eCParameterSpec.getCurve(); ECField field = curve.getField(); if (!(field instanceof ECFieldFp)) { StringBuilder sb = new StringBuilder("Only prime field supported (for now), found "); sb.append(field.getClass().getCanonicalName()); throw new IllegalArgumentException(sb.toString()); } int cofactor = eCParameterSpec.getCofactor(); ECCurve.Fp fp = new ECCurve.Fp(getPrime(eCParameterSpec), curve.getA(), curve.getB(), eCParameterSpec.getOrder(), BigInteger.valueOf(cofactor)); int i4 = a + 29; f = i4 % 128; int i5 = i4 % 2; return fp; } public static ECPublicKeyParameters toBouncyECPublicKeyParameters(ECPublicKey eCPublicKey) { int i = 2 % 2; ECParameterSpec params = eCPublicKey.getParams(); ECPublicKeyParameters eCPublicKeyParameters = new ECPublicKeyParameters(toBouncyCastleECPoint(eCPublicKey.getW(), params), toBouncyECDomainParameters(params)); int i2 = f + 75; a = i2 % 128; if (i2 % 2 == 0) { return eCPublicKeyParameters; } Object obj = null; obj.hashCode(); throw null; } public static ECPrivateKeyParameters toBouncyECPrivateKeyParameters(ECPrivateKey eCPrivateKey) { int i = 2 % 2; ECPrivateKeyParameters eCPrivateKeyParameters = new ECPrivateKeyParameters(eCPrivateKey.getS(), toBouncyECDomainParameters(eCPrivateKey.getParams())); int i2 = a + 105; f = i2 % 128; int i3 = i2 % 2; return eCPrivateKeyParameters; } public static ECDomainParameters toBouncyECDomainParameters(ECParameterSpec eCParameterSpec) { int i = 2 % 2; ECDomainParameters eCDomainParameters = new ECDomainParameters(toBouncyCastleECCurve(eCParameterSpec), toBouncyCastleECPoint(eCParameterSpec.getGenerator(), eCParameterSpec), eCParameterSpec.getOrder(), BigInteger.valueOf(eCParameterSpec.getCofactor()), eCParameterSpec.getCurve().getSeed()); int i2 = a + 75; f = i2 % 128; int i3 = i2 % 2; return eCDomainParameters; } static void b() { b = (char) 61421; c = (char) 40277; e = (char) 57184; d = (char) 7066; } public static AlgorithmParameterSpec mapNonceIM(byte[] bArr, byte[] bArr2, byte[] bArr3, AlgorithmParameterSpec algorithmParameterSpec) { int i = 2 % 2; int i2 = a + 91; f = i2 % 128; if (i2 % 2 != 0) { return null; } int i3 = 41 / 0; return null; } }