347 lines
14 KiB
Java
347 lines
14 KiB
Java
package org.bouncycastle.crypto.signers;
|
|
|
|
import android.graphics.Color;
|
|
import android.os.Process;
|
|
import android.os.SystemClock;
|
|
import android.text.TextUtils;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
import android.view.ViewConfiguration;
|
|
import java.lang.reflect.Method;
|
|
import java.math.BigInteger;
|
|
import java.security.SecureRandom;
|
|
import o.xzZ;
|
|
import o.zUI;
|
|
import org.bouncycastle.crypto.DSA;
|
|
import org.bouncycastle.crypto.params.GOST3410KeyParameters;
|
|
import org.bouncycastle.crypto.params.GOST3410Parameters;
|
|
import org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters;
|
|
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class GOST3410Signer implements DSA {
|
|
GOST3410KeyParameters key;
|
|
SecureRandom random;
|
|
private static final byte[] $$a = {45, 6, -13, -19};
|
|
private static final int $$b = 216;
|
|
private static int $10 = 0;
|
|
private static int $11 = 1;
|
|
private static int e = 0;
|
|
private static int b = 1;
|
|
private static int a = 2015661793;
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:10:0x0027 */
|
|
/* JADX WARN: Removed duplicated region for block: B:7:0x001f */
|
|
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:10:0x0027 -> B:4:0x0029). Please report as a decompilation issue!!! */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
private static void f(short r6, short r7, short r8, java.lang.Object[] r9) {
|
|
/*
|
|
byte[] r0 = org.bouncycastle.crypto.signers.GOST3410Signer.$$a
|
|
int r6 = r6 * 2
|
|
int r6 = 1 - r6
|
|
int r8 = r8 * 7
|
|
int r8 = 76 - r8
|
|
int r7 = r7 * 3
|
|
int r7 = 4 - r7
|
|
byte[] r1 = new byte[r6]
|
|
r2 = 0
|
|
if (r0 != 0) goto L17
|
|
r3 = r8
|
|
r5 = r2
|
|
r8 = r6
|
|
goto L29
|
|
L17:
|
|
r3 = r2
|
|
L18:
|
|
byte r4 = (byte) r8
|
|
int r5 = r3 + 1
|
|
r1[r3] = r4
|
|
if (r5 != r6) goto L27
|
|
java.lang.String r6 = new java.lang.String
|
|
r6.<init>(r1, r2)
|
|
r9[r2] = r6
|
|
return
|
|
L27:
|
|
r3 = r0[r7]
|
|
L29:
|
|
int r8 = r8 + r3
|
|
int r7 = r7 + 1
|
|
r3 = r5
|
|
goto L18
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.signers.GOST3410Signer.f(short, short, short, java.lang.Object[]):void");
|
|
}
|
|
|
|
private static void c(int i, int i2, int i3, char[] cArr, boolean z, Object[] objArr) {
|
|
char[] cArr2;
|
|
int i4 = 2 % 2;
|
|
zUI zui = new zUI();
|
|
char[] cArr3 = new char[i];
|
|
zui.d = 0;
|
|
while (zui.d < i) {
|
|
int i5 = $11 + 73;
|
|
$10 = i5 % 128;
|
|
int i6 = i5 % 2;
|
|
zui.c = cArr[zui.d];
|
|
cArr3[zui.d] = (char) (i3 + zui.c);
|
|
int i7 = zui.d;
|
|
try {
|
|
Object[] objArr2 = {Integer.valueOf(cArr3[i7]), Integer.valueOf(a)};
|
|
Object obj = xzZ.y.get(880493502);
|
|
if (obj == null) {
|
|
Class cls = (Class) xzZ.c(144 - (SystemClock.currentThreadTimeMillis() > (-1L) ? 1 : (SystemClock.currentThreadTimeMillis() == (-1L) ? 0 : -1)), (ViewConfiguration.getFadingEdgeLength() >> 16) + 7, (char) Color.alpha(0));
|
|
byte b2 = (byte) 0;
|
|
byte b3 = b2;
|
|
Object[] objArr3 = new Object[1];
|
|
f(b2, b3, (byte) (b3 + 1), objArr3);
|
|
obj = cls.getMethod((String) objArr3[0], Integer.TYPE, Integer.TYPE);
|
|
xzZ.y.put(880493502, obj);
|
|
}
|
|
cArr3[i7] = ((Character) ((Method) obj).invoke(null, objArr2)).charValue();
|
|
try {
|
|
Object[] objArr4 = {zui, zui};
|
|
Object obj2 = xzZ.y.get(1294990079);
|
|
if (obj2 == null) {
|
|
Class cls2 = (Class) xzZ.c(342 - Color.blue(0), 5 - Color.red(0), (char) ((-1) - TextUtils.lastIndexOf("", '0', 0)));
|
|
byte b4 = (byte) 0;
|
|
byte b5 = b4;
|
|
Object[] objArr5 = new Object[1];
|
|
f(b4, b5, b5, objArr5);
|
|
obj2 = cls2.getMethod((String) objArr5[0], Object.class, Object.class);
|
|
xzZ.y.put(1294990079, obj2);
|
|
}
|
|
((Method) obj2).invoke(null, objArr4);
|
|
int i8 = $11 + 19;
|
|
$10 = i8 % 128;
|
|
int i9 = i8 % 2;
|
|
} catch (Throwable th) {
|
|
Throwable cause = th.getCause();
|
|
if (cause == null) {
|
|
throw th;
|
|
}
|
|
throw cause;
|
|
}
|
|
} catch (Throwable th2) {
|
|
Throwable cause2 = th2.getCause();
|
|
if (cause2 == null) {
|
|
throw th2;
|
|
}
|
|
throw cause2;
|
|
}
|
|
}
|
|
if (i2 > 0) {
|
|
zui.a = i2;
|
|
char[] cArr4 = new char[i];
|
|
System.arraycopy(cArr3, 0, cArr4, 0, i);
|
|
System.arraycopy(cArr4, 0, cArr3, i - zui.a, zui.a);
|
|
System.arraycopy(cArr4, zui.a, cArr3, 0, i - zui.a);
|
|
}
|
|
if (z) {
|
|
int i10 = $10 + 13;
|
|
$11 = i10 % 128;
|
|
if (i10 % 2 == 0) {
|
|
cArr2 = new char[i];
|
|
zui.d = 1;
|
|
} else {
|
|
cArr2 = new char[i];
|
|
zui.d = 0;
|
|
}
|
|
while (zui.d < i) {
|
|
cArr2[zui.d] = cArr3[(i - zui.d) - 1];
|
|
try {
|
|
Object[] objArr6 = {zui, zui};
|
|
Object obj3 = xzZ.y.get(1294990079);
|
|
if (obj3 == null) {
|
|
Class cls3 = (Class) xzZ.c((SystemClock.elapsedRealtime() > 0L ? 1 : (SystemClock.elapsedRealtime() == 0L ? 0 : -1)) + 341, 4 - TextUtils.lastIndexOf("", '0'), (char) TextUtils.getOffsetBefore("", 0));
|
|
byte b6 = (byte) 0;
|
|
byte b7 = b6;
|
|
Object[] objArr7 = new Object[1];
|
|
f(b6, b7, b7, objArr7);
|
|
obj3 = cls3.getMethod((String) objArr7[0], Object.class, Object.class);
|
|
xzZ.y.put(1294990079, obj3);
|
|
}
|
|
((Method) obj3).invoke(null, objArr6);
|
|
} catch (Throwable th3) {
|
|
Throwable cause3 = th3.getCause();
|
|
if (cause3 == null) {
|
|
throw th3;
|
|
}
|
|
throw cause3;
|
|
}
|
|
}
|
|
cArr3 = cArr2;
|
|
}
|
|
objArr[0] = new String(cArr3);
|
|
}
|
|
|
|
@Override // org.bouncycastle.crypto.DSA
|
|
public boolean verifySignature(byte[] bArr, BigInteger bigInteger, BigInteger bigInteger2) {
|
|
int i = 2 % 2;
|
|
int i2 = e + 113;
|
|
b = i2 % 128;
|
|
int i3 = i2 % 2;
|
|
int length = bArr.length;
|
|
byte[] bArr2 = new byte[length];
|
|
int i4 = 0;
|
|
while (i4 != length) {
|
|
int i5 = b + 83;
|
|
e = i5 % 128;
|
|
if (i5 % 2 != 0) {
|
|
bArr2[i4] = bArr[(length + 1) * i4];
|
|
i4 += 112;
|
|
} else {
|
|
bArr2[i4] = bArr[(length - 1) - i4];
|
|
i4++;
|
|
}
|
|
}
|
|
BigInteger bigInteger3 = new BigInteger(1, bArr2);
|
|
GOST3410Parameters parameters = this.key.getParameters();
|
|
BigInteger valueOf = BigInteger.valueOf(0L);
|
|
if (valueOf.compareTo(bigInteger) < 0) {
|
|
int i6 = e + 73;
|
|
b = i6 % 128;
|
|
int i7 = i6 % 2;
|
|
if (parameters.getQ().compareTo(bigInteger) > 0) {
|
|
int i8 = b + 45;
|
|
e = i8 % 128;
|
|
if (i8 % 2 != 0) {
|
|
valueOf.compareTo(bigInteger2);
|
|
Object obj = null;
|
|
obj.hashCode();
|
|
throw null;
|
|
}
|
|
if (valueOf.compareTo(bigInteger2) < 0 && parameters.getQ().compareTo(bigInteger2) > 0) {
|
|
BigInteger q = parameters.getQ();
|
|
Object[] objArr = new Object[1];
|
|
c(-((byte) KeyEvent.getModifierMetaStateMask()), View.resolveSizeAndState(0, 0, 0) + 1, 248 - (Process.myPid() >> 22), new char[]{0}, false, objArr);
|
|
BigInteger modPow = bigInteger3.modPow(q.subtract(new BigInteger(((String) objArr[0]).intern())), parameters.getQ());
|
|
return parameters.getA().modPow(bigInteger2.multiply(modPow).mod(parameters.getQ()), parameters.getP()).multiply(((GOST3410PublicKeyParameters) this.key).getY().modPow(parameters.getQ().subtract(bigInteger).multiply(modPow).mod(parameters.getQ()), parameters.getP())).mod(parameters.getP()).mod(parameters.getQ()).equals(bigInteger);
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:10:0x0019, code lost:
|
|
|
|
if ((r5 instanceof org.bouncycastle.crypto.params.ParametersWithRandom) == false) goto L12;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:11:0x001b, code lost:
|
|
|
|
r5 = (org.bouncycastle.crypto.params.ParametersWithRandom) r5;
|
|
r3.random = r5.getRandom();
|
|
r3.key = (org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters) r5.getParameters();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:12:0x002b, code lost:
|
|
|
|
return;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:13:0x002c, code lost:
|
|
|
|
r3.random = new java.security.SecureRandom();
|
|
r5 = (org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters) r5;
|
|
r4 = org.bouncycastle.crypto.signers.GOST3410Signer.b + 77;
|
|
org.bouncycastle.crypto.signers.GOST3410Signer.e = r4 % 128;
|
|
r4 = r4 % 2;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:14:0x0015, code lost:
|
|
|
|
if (r4 != false) goto L8;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:4:0x0012, code lost:
|
|
|
|
if (r4 != false) goto L8;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:5:0x003f, code lost:
|
|
|
|
r5 = (org.bouncycastle.crypto.params.GOST3410PublicKeyParameters) r5;
|
|
*/
|
|
@Override // org.bouncycastle.crypto.DSA
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void init(boolean r4, org.bouncycastle.crypto.CipherParameters r5) {
|
|
/*
|
|
r3 = this;
|
|
r0 = 2
|
|
int r1 = r0 % r0
|
|
int r1 = org.bouncycastle.crypto.signers.GOST3410Signer.b
|
|
int r1 = r1 + 37
|
|
int r2 = r1 % 128
|
|
org.bouncycastle.crypto.signers.GOST3410Signer.e = r2
|
|
int r1 = r1 % r0
|
|
if (r1 == 0) goto L15
|
|
r1 = 73
|
|
int r1 = r1 / 0
|
|
if (r4 == 0) goto L3f
|
|
goto L17
|
|
L15:
|
|
if (r4 == 0) goto L3f
|
|
L17:
|
|
boolean r4 = r5 instanceof org.bouncycastle.crypto.params.ParametersWithRandom
|
|
if (r4 == 0) goto L2c
|
|
org.bouncycastle.crypto.params.ParametersWithRandom r5 = (org.bouncycastle.crypto.params.ParametersWithRandom) r5
|
|
java.security.SecureRandom r4 = r5.getRandom()
|
|
r3.random = r4
|
|
org.bouncycastle.crypto.CipherParameters r4 = r5.getParameters()
|
|
org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters r4 = (org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters) r4
|
|
r3.key = r4
|
|
return
|
|
L2c:
|
|
java.security.SecureRandom r4 = new java.security.SecureRandom
|
|
r4.<init>()
|
|
r3.random = r4
|
|
org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters r5 = (org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters) r5
|
|
int r4 = org.bouncycastle.crypto.signers.GOST3410Signer.b
|
|
int r4 = r4 + 77
|
|
int r1 = r4 % 128
|
|
org.bouncycastle.crypto.signers.GOST3410Signer.e = r1
|
|
int r4 = r4 % r0
|
|
goto L41
|
|
L3f:
|
|
org.bouncycastle.crypto.params.GOST3410PublicKeyParameters r5 = (org.bouncycastle.crypto.params.GOST3410PublicKeyParameters) r5
|
|
L41:
|
|
r3.key = r5
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.signers.GOST3410Signer.init(boolean, org.bouncycastle.crypto.CipherParameters):void");
|
|
}
|
|
|
|
@Override // org.bouncycastle.crypto.DSA
|
|
public BigInteger[] generateSignature(byte[] bArr) {
|
|
BigInteger bigInteger;
|
|
int i = 2 % 2;
|
|
int length = bArr.length;
|
|
byte[] bArr2 = new byte[length];
|
|
int i2 = e + 91;
|
|
b = i2 % 128;
|
|
int i3 = i2 % 2;
|
|
int i4 = 0;
|
|
while (i4 != length) {
|
|
int i5 = b + 83;
|
|
e = i5 % 128;
|
|
if (i5 % 2 != 0) {
|
|
bArr2[i4] = bArr[length / i4];
|
|
i4 += 44;
|
|
} else {
|
|
bArr2[i4] = bArr[(length - 1) - i4];
|
|
i4++;
|
|
}
|
|
}
|
|
BigInteger bigInteger2 = new BigInteger(1, bArr2);
|
|
GOST3410Parameters parameters = this.key.getParameters();
|
|
do {
|
|
bigInteger = new BigInteger(parameters.getQ().bitLength(), this.random);
|
|
} while (bigInteger.compareTo(parameters.getQ()) >= 0);
|
|
int i6 = e + 107;
|
|
b = i6 % 128;
|
|
int i7 = i6 % 2;
|
|
BigInteger mod = parameters.getA().modPow(bigInteger, parameters.getP()).mod(parameters.getQ());
|
|
return new BigInteger[]{mod, bigInteger.multiply(bigInteger2).add(((GOST3410PrivateKeyParameters) this.key).getX().multiply(mod)).mod(parameters.getQ())};
|
|
}
|
|
}
|