package org.bouncycastle.crypto.generators; import android.graphics.drawable.Drawable; import android.view.ViewConfiguration; import android.widget.ExpandableListView; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.common.base.Ascii; import com.google.common.primitives.UnsignedBytes; import java.io.ByteArrayOutputStream; import net.sf.scuba.smartcards.ISO7816; import net.sf.scuba.smartcards.ISOFileInfo; import org.bouncycastle.crypto.DataLengthException; import org.bouncycastle.util.Strings; import org.jmrtd.lds.CVCAFile; /* loaded from: classes6.dex */ public class OpenBSDBCrypt { private static final byte[] $$a = {75, -3, Ascii.EM, 97}; private static final int $$b = 8; private static int $10 = 0; private static int $11 = 1; private static int a = 0; private static byte[] b = null; private static int c = 0; private static int d = 0; private static final byte[] decodingTable; private static short[] e = null; private static final byte[] encodingTable; private static int f = 0; private static int g = 0; private static final String version = "2a"; private static void i(int i, byte b2, short s, Object[] objArr) { int i2 = (i * 2) + 108; byte[] bArr = $$a; int i3 = b2 * 3; int i4 = 3 - (s * 3); byte[] bArr2 = new byte[i3 + 1]; int i5 = -1; if (bArr == null) { i2 = (-i2) + i3; i4 = i4; i5 = -1; } while (true) { int i6 = i5 + 1; int i7 = i4 + 1; bArr2[i6] = (byte) i2; if (i6 == i3) { objArr[0] = new String(bArr2, 0); return; } i2 = (-bArr[i7]) + i2; i4 = i7; i5 = i6; } } /* JADX WARN: Code restructure failed: missing block: B:15:0x009c, code lost: if (r3 != null) goto L21; */ /* JADX WARN: Code restructure failed: missing block: B:16:0x0121, code lost: if (r3 == null) goto L39; */ /* JADX WARN: Code restructure failed: missing block: B:17:0x0123, code lost: r0 = org.bouncycastle.crypto.generators.OpenBSDBCrypt.b; */ /* JADX WARN: Code restructure failed: missing block: B:18:0x0128, code lost: r9 = new java.lang.Object[]{java.lang.Integer.valueOf(r23), java.lang.Integer.valueOf(org.bouncycastle.crypto.generators.OpenBSDBCrypt.a)}; r3 = o.xzZ.y.get(-2092856797); */ /* JADX WARN: Code restructure failed: missing block: B:19:0x0143, code lost: if (r3 == null) goto L36; */ /* JADX WARN: Code restructure failed: missing block: B:22:0x019c, code lost: r3 = (byte) (((byte) (r0[((java.lang.Integer) ((java.lang.reflect.Method) r3).invoke(null, r9)).intValue()] ^ (-7303220121662775787L))) + ((int) (org.bouncycastle.crypto.generators.OpenBSDBCrypt.c ^ (-7303220121662775787L)))); */ /* JADX WARN: Code restructure failed: missing block: B:23:0x0146, code lost: r3 = (java.lang.Class) o.xzZ.c(android.view.KeyEvent.normalizeMetaState(0) + 337, 5 - (android.media.AudioTrack.getMinVolume() > com.google.android.gms.maps.model.BitmapDescriptorFactory.HUE_RED ? 1 : (android.media.AudioTrack.getMinVolume() == com.google.android.gms.maps.model.BitmapDescriptorFactory.HUE_RED ? 0 : -1)), (char) ((android.os.SystemClock.elapsedRealtimeNanos() > 0 ? 1 : (android.os.SystemClock.elapsedRealtimeNanos() == 0 ? 0 : -1)) - 1)); r7 = (byte) 1; r10 = (byte) (r7 - 1); r12 = new java.lang.Object[1]; i(r7, r10, r10, r12); r3 = r3.getMethod((java.lang.String) r12[0], java.lang.Integer.TYPE, java.lang.Integer.TYPE); o.xzZ.y.put(-2092856797, r3); */ /* JADX WARN: Code restructure failed: missing block: B:24:0x01af, code lost: r3 = (short) (((short) (org.bouncycastle.crypto.generators.OpenBSDBCrypt.e[r23 + ((int) (org.bouncycastle.crypto.generators.OpenBSDBCrypt.a ^ (-7303220121662775787L)))] ^ (-7303220121662775787L))) + ((int) (org.bouncycastle.crypto.generators.OpenBSDBCrypt.c ^ (-7303220121662775787L)))); */ /* JADX WARN: Code restructure failed: missing block: B:25:0x00a3, code lost: r15 = r3.length; r13 = new byte[r15]; r14 = 0; */ /* JADX WARN: Code restructure failed: missing block: B:26:0x00a7, code lost: if (r14 >= r15) goto L83; */ /* JADX WARN: Code restructure failed: missing block: B:27:0x00a9, code lost: r9 = org.bouncycastle.crypto.generators.OpenBSDBCrypt.$10 + 47; org.bouncycastle.crypto.generators.OpenBSDBCrypt.$11 = r9 % 128; r9 = r9 % r0; */ /* JADX WARN: Code restructure failed: missing block: B:28:0x00b4, code lost: r9 = new java.lang.Object[]{java.lang.Integer.valueOf(r3[r14])}; r0 = o.xzZ.y.get(-1648115392); */ /* JADX WARN: Code restructure failed: missing block: B:29:0x00c9, code lost: if (r0 == null) goto L27; */ /* JADX WARN: Code restructure failed: missing block: B:32:0x0113, code lost: r13[r14] = ((java.lang.Byte) ((java.lang.reflect.Method) r0).invoke(null, r9)).byteValue(); r14 = r14 + 1; r0 = 2; r11 = 0; */ /* JADX WARN: Code restructure failed: missing block: B:33:0x00cc, code lost: r0 = (java.lang.Class) o.xzZ.c((android.view.ViewConfiguration.getScrollBarFadeDuration() >> 16) + 60, (android.widget.ExpandableListView.getPackedPositionForChild(0, 0) > r11 ? 1 : (android.widget.ExpandableListView.getPackedPositionForChild(0, 0) == r11 ? 0 : -1)) + 6, (char) android.text.TextUtils.getOffsetAfter("", 0)); r7 = (byte) 0; r11 = r7; r10 = new java.lang.Object[1]; i(r7, r11, r11, r10); r0 = r0.getMethod((java.lang.String) r10[0], java.lang.Integer.TYPE); o.xzZ.y.put(-1648115392, r0); */ /* JADX WARN: Code restructure failed: missing block: B:35:0x0120, code lost: r3 = r13; */ /* JADX WARN: Code restructure failed: missing block: B:37:0x00a1, code lost: if (r3 != null) goto L21; */ /* JADX WARN: Code restructure failed: missing block: B:42:0x01e7, code lost: if (r4 != false) goto L48; */ /* JADX WARN: Code restructure failed: missing block: B:43:0x01fd, code lost: r4 = 0; */ /* JADX WARN: Code restructure failed: missing block: B:75:0x01fb, code lost: r4 = 1; */ /* JADX WARN: Code restructure failed: missing block: B:77:0x01f9, code lost: if (r4 != false) goto L48; */ /* JADX WARN: Removed duplicated region for block: B:85:0x0329 */ /* JADX WARN: Removed duplicated region for block: B:86:0x032a */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static void h(short r20, byte r21, int r22, int r23, int r24, java.lang.Object[] r25) { /* Method dump skipped, instructions count: 811 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.generators.OpenBSDBCrypt.h(short, byte, int, int, int, java.lang.Object[]):void"); } static void b() { a = 1300823559; c = 1406017066; d = 274992821; b = new byte[]{-41}; } /* JADX WARN: Code restructure failed: missing block: B:24:0x003a, code lost: if (r4.length < 72) goto L23; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static java.lang.String generate(char[] r4, byte[] r5, int r6) { /* r0 = 2 int r1 = r0 % r0 if (r4 == 0) goto L79 if (r5 == 0) goto L71 int r1 = r5.length r2 = 16 if (r1 != r2) goto L5c r1 = 4 if (r6 < r1) goto L54 int r1 = org.bouncycastle.crypto.generators.OpenBSDBCrypt.f int r2 = r1 + 109 int r3 = r2 % 128 org.bouncycastle.crypto.generators.OpenBSDBCrypt.g = r3 int r2 = r2 % r0 r3 = 72 if (r2 != 0) goto L1f if (r6 > r3) goto L54 goto L23 L1f: r2 = 31 if (r6 > r2) goto L54 L23: int r1 = r1 + 3 int r2 = r1 % 128 org.bouncycastle.crypto.generators.OpenBSDBCrypt.g = r2 int r1 = r1 % r0 byte[] r4 = org.bouncycastle.util.Strings.toUTF8ByteArray(r4) if (r1 != 0) goto L39 int r0 = r4.length r1 = 10 if (r0 >= r1) goto L36 goto L3c L36: r3 = 85 goto L3f L39: int r0 = r4.length if (r0 >= r3) goto L3f L3c: int r0 = r4.length int r3 = r0 + 1 L3f: byte[] r0 = new byte[r3] int r1 = r4.length if (r3 <= r1) goto L45 int r3 = r4.length L45: r1 = 0 java.lang.System.arraycopy(r4, r1, r0, r1, r3) org.bouncycastle.util.Arrays.fill(r4, r1) java.lang.String r4 = createBcryptString(r0, r5, r6) org.bouncycastle.util.Arrays.fill(r0, r1) return r4 L54: java.lang.IllegalArgumentException r4 = new java.lang.IllegalArgumentException java.lang.String r5 = "Invalid cost factor." r4.(r5) throw r4 L5c: org.bouncycastle.crypto.DataLengthException r4 = new org.bouncycastle.crypto.DataLengthException java.lang.StringBuilder r6 = new java.lang.StringBuilder java.lang.String r0 = "16 byte salt required: " r6.(r0) int r5 = r5.length r6.append(r5) java.lang.String r5 = r6.toString() r4.(r5) throw r4 L71: java.lang.IllegalArgumentException r4 = new java.lang.IllegalArgumentException java.lang.String r5 = "Salt required." r4.(r5) throw r4 L79: java.lang.IllegalArgumentException r4 = new java.lang.IllegalArgumentException java.lang.String r5 = "Password required." r4.(r5) throw r4 */ throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.generators.OpenBSDBCrypt.generate(char[], byte[], int):java.lang.String"); } private static String encodeData(byte[] bArr) { boolean z; int length; int i = 2 % 2; if (bArr.length != 24) { int i2 = g + 23; f = i2 % 128; if (i2 % 2 == 0 ? bArr.length != 16 : bArr.length != 32) { StringBuilder sb = new StringBuilder("Invalid length: "); sb.append(bArr.length); sb.append(", 24 for key or 16 for salt expected"); throw new DataLengthException(sb.toString()); } } if (bArr.length == 16) { byte[] bArr2 = new byte[18]; System.arraycopy(bArr, 0, bArr2, 0, bArr.length); bArr = bArr2; z = true; } else { bArr[bArr.length - 1] = 0; z = false; } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int length2 = bArr.length; for (int i3 = 0; i3 < length2; i3 += 3) { int i4 = f + 5; g = i4 % 128; int i5 = i4 % 2; int i6 = bArr[i3] & UnsignedBytes.MAX_VALUE; int i7 = bArr[i3 + 1] & UnsignedBytes.MAX_VALUE; byte b2 = bArr[i3 + 2]; byte[] bArr3 = encodingTable; byteArrayOutputStream.write(bArr3[(i6 >>> 2) & 63]); byteArrayOutputStream.write(bArr3[((i6 << 4) | (i7 >>> 4)) & 63]); byteArrayOutputStream.write(bArr3[((i7 << 2) | ((b2 & UnsignedBytes.MAX_VALUE) >>> 6)) & 63]); byteArrayOutputStream.write(bArr3[b2 & 63]); } String fromByteArray = Strings.fromByteArray(byteArrayOutputStream.toByteArray()); if (z) { int i8 = g + 39; f = i8 % 128; int i9 = i8 % 2; length = 22; } else { length = fromByteArray.length() - 1; } String substring = fromByteArray.substring(0, length); int i10 = g + 71; f = i10 % 128; int i11 = i10 % 2; return substring; } /* JADX WARN: Removed duplicated region for block: B:16:0x003d A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:20:0x003a A[SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static byte[] decodeSaltString(java.lang.String r11) { /* r0 = 2 int r1 = r0 % r0 char[] r11 = r11.toCharArray() java.io.ByteArrayOutputStream r1 = new java.io.ByteArrayOutputStream r2 = 16 r1.(r2) int r3 = r11.length r4 = 22 if (r3 != r4) goto La4 r3 = 0 r4 = r3 L15: int r5 = r11.length if (r4 >= r5) goto L4d char r5 = r11[r4] r6 = 122(0x7a, float:1.71E-43) if (r5 > r6) goto L3d r6 = 46 if (r5 < r6) goto L3d int r6 = org.bouncycastle.crypto.generators.OpenBSDBCrypt.g int r6 = r6 + 119 int r7 = r6 % 128 org.bouncycastle.crypto.generators.OpenBSDBCrypt.f = r7 int r6 = r6 % r0 if (r6 == 0) goto L32 r6 = 33 if (r5 <= r6) goto L3a goto L36 L32: r6 = 57 if (r5 <= r6) goto L3a L36: r6 = 65 if (r5 < r6) goto L3d L3a: int r4 = r4 + 1 goto L15 L3d: java.lang.IllegalArgumentException r11 = new java.lang.IllegalArgumentException java.lang.String r0 = "Salt string contains invalid character: " java.lang.String r1 = java.lang.String.valueOf(r5) java.lang.String r0 = r0.concat(r1) r11.(r0) throw r11 L4d: r4 = 24 char[] r5 = new char[r4] int r6 = r11.length java.lang.System.arraycopy(r11, r3, r5, r3, r6) int r11 = org.bouncycastle.crypto.generators.OpenBSDBCrypt.g int r11 = r11 + 89 int r6 = r11 % 128 org.bouncycastle.crypto.generators.OpenBSDBCrypt.f = r6 int r11 = r11 % r0 r11 = r3 L5f: if (r11 >= r4) goto L9a int r6 = org.bouncycastle.crypto.generators.OpenBSDBCrypt.g int r6 = r6 + 123 int r7 = r6 % 128 org.bouncycastle.crypto.generators.OpenBSDBCrypt.f = r7 int r6 = r6 % r0 byte[] r6 = org.bouncycastle.crypto.generators.OpenBSDBCrypt.decodingTable char r7 = r5[r11] r7 = r6[r7] int r8 = r11 + 1 char r8 = r5[r8] r8 = r6[r8] int r9 = r11 + 2 char r9 = r5[r9] r9 = r6[r9] int r10 = r11 + 3 char r10 = r5[r10] r6 = r6[r10] int r7 = r7 << r0 int r10 = r8 >> 4 r7 = r7 | r10 r1.write(r7) int r7 = r8 << 4 int r8 = r9 >> 2 r7 = r7 | r8 r1.write(r7) int r7 = r9 << 6 r6 = r6 | r7 r1.write(r6) int r11 = r11 + 4 goto L5f L9a: byte[] r11 = r1.toByteArray() byte[] r0 = new byte[r2] java.lang.System.arraycopy(r11, r3, r0, r3, r2) return r0 La4: org.bouncycastle.crypto.DataLengthException r0 = new org.bouncycastle.crypto.DataLengthException java.lang.StringBuilder r1 = new java.lang.StringBuilder java.lang.String r2 = "Invalid base64 salt length: " r1.(r2) int r11 = r11.length r1.append(r11) java.lang.String r11 = " , 22 required." r1.append(r11) java.lang.String r11 = r1.toString() r0.(r11) throw r0 */ throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.generators.OpenBSDBCrypt.decodeSaltString(java.lang.String):byte[]"); } private static String createBcryptString(byte[] bArr, byte[] bArr2, int i) { String num; int i2 = 2 % 2; StringBuffer stringBuffer = new StringBuffer(60); stringBuffer.append("$2a$"); if (i < 10) { Object[] objArr = new Object[1]; h((short) Drawable.resolveOpacity(0, 0), (byte) (ExpandableListView.getPackedPositionChild(0L) - 84), (-64) - (ViewConfiguration.getKeyRepeatTimeout() >> 16), (-507961362) - Drawable.resolveOpacity(0, 0), (-1135218799) - (ViewConfiguration.getScrollFriction() > BitmapDescriptorFactory.HUE_RED ? 1 : (ViewConfiguration.getScrollFriction() == BitmapDescriptorFactory.HUE_RED ? 0 : -1)), objArr); StringBuilder sb = new StringBuilder(((String) objArr[0]).intern()); sb.append(i); num = sb.toString(); } else { num = Integer.toString(i); } stringBuffer.append(num); stringBuffer.append('$'); stringBuffer.append(encodeData(bArr2)); stringBuffer.append(encodeData(BCrypt.generate(bArr, bArr2, i))); String obj = stringBuffer.toString(); int i3 = g + 59; f = i3 % 128; if (i3 % 2 != 0) { int i4 = 54 / 0; } return obj; } public static boolean checkPassword(String str, char[] cArr) { int i = 2 % 2; int i2 = g + 39; f = i2 % 128; int i3 = i2 % 2; if (str.length() != 60) { StringBuilder sb = new StringBuilder("Bcrypt String length: "); sb.append(str.length()); sb.append(", 60 required."); throw new DataLengthException(sb.toString()); } if (str.charAt(0) != '$' || str.charAt(3) != '$' || str.charAt(6) != '$') { throw new IllegalArgumentException("Invalid Bcrypt String format."); } if (!str.substring(1, 3).equals(version)) { throw new IllegalArgumentException("Wrong Bcrypt version, 2a expected."); } try { int parseInt = Integer.parseInt(str.substring(4, 6)); if (parseInt >= 4) { int i4 = g + 27; f = i4 % 128; int i5 = i4 % 2; if (parseInt <= 31) { if (cArr != null) { return str.equals(generate(cArr, decodeSaltString(str.substring(str.lastIndexOf(36) + 1, str.length() - 31)), parseInt)); } throw new IllegalArgumentException("Missing password."); } } StringBuilder sb2 = new StringBuilder("Invalid cost factor: "); sb2.append(parseInt); sb2.append(", 4 < cost < 31 expected."); throw new IllegalArgumentException(sb2.toString()); } catch (NumberFormatException unused) { StringBuilder sb3 = new StringBuilder("Invalid cost factor: "); sb3.append(str.substring(4, 6)); throw new IllegalArgumentException(sb3.toString()); } } static { int i = 0; f = 0; g = 1; b(); encodingTable = new byte[]{46, 47, 65, CVCAFile.CAR_TAG, 67, ISO7816.INS_REHABILITATE_CHV, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, ISOFileInfo.FCP_BYTE, 99, ISOFileInfo.FMD_BYTE, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, ISOFileInfo.FCI_BYTE, ISO7816.INS_MANAGE_CHANNEL, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, ISO7816.INS_DECREASE, 49, ISO7816.INS_INCREASE, 51, ISO7816.INS_DECREASE_STAMPED, 53, 54, 55, 56, 57}; decodingTable = new byte[128]; int i2 = 0; while (true) { byte[] bArr = decodingTable; if (i2 >= bArr.length) { break; } bArr[i2] = -1; i2++; int i3 = f + 79; g = i3 % 128; if (i3 % 2 == 0) { int i4 = 2 / 3; } else { int i5 = 2 % 2; } } while (true) { byte[] bArr2 = encodingTable; if (i >= bArr2.length) { return; } int i6 = g + 121; f = i6 % 128; int i7 = i6 % 2; decodingTable[bArr2[i]] = (byte) i; i++; int i8 = 2 % 2; } } }