82 lines
3.4 KiB
Java
82 lines
3.4 KiB
Java
|
package o;
|
||
|
|
||
|
import java.io.ByteArrayOutputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.math.BigInteger;
|
||
|
import java.security.SignatureException;
|
||
|
import java.util.Locale;
|
||
|
import org.bouncycastle.asn1.ASN1EncodableVector;
|
||
|
import org.bouncycastle.asn1.ASN1InputStream;
|
||
|
import org.bouncycastle.asn1.ASN1Integer;
|
||
|
import org.bouncycastle.asn1.ASN1Sequence;
|
||
|
import org.bouncycastle.asn1.DEROutputStream;
|
||
|
import org.bouncycastle.asn1.DERSequence;
|
||
|
|
||
|
/* renamed from: o.gmi, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class C15294gmi {
|
||
|
public static byte[] c(String str, byte[] bArr) throws IOException {
|
||
|
byte[] bArr2;
|
||
|
if (!str.toUpperCase(Locale.getDefault()).contains("ECDSA")) {
|
||
|
return bArr;
|
||
|
}
|
||
|
ASN1InputStream aSN1InputStream = new ASN1InputStream(bArr);
|
||
|
try {
|
||
|
ASN1Sequence aSN1Sequence = (ASN1Sequence) aSN1InputStream.readObject();
|
||
|
aSN1InputStream.close();
|
||
|
BigInteger value = ((ASN1Integer) aSN1Sequence.getObjectAt(0)).getValue();
|
||
|
BigInteger value2 = ((ASN1Integer) aSN1Sequence.getObjectAt(1)).getValue();
|
||
|
byte[] byteArray = value.toByteArray();
|
||
|
if (byteArray[0] == 0) {
|
||
|
int length = byteArray.length - 1;
|
||
|
byte[] bArr3 = new byte[length];
|
||
|
System.arraycopy(byteArray, 1, bArr3, 0, length);
|
||
|
byteArray = bArr3;
|
||
|
}
|
||
|
byte[] byteArray2 = value2.toByteArray();
|
||
|
if (byteArray2[0] == 0) {
|
||
|
int length2 = byteArray2.length - 1;
|
||
|
byte[] bArr4 = new byte[length2];
|
||
|
System.arraycopy(byteArray2, 1, bArr4, 0, length2);
|
||
|
byteArray2 = bArr4;
|
||
|
}
|
||
|
if (byteArray.length > byteArray2.length) {
|
||
|
bArr2 = new byte[byteArray.length << 1];
|
||
|
} else {
|
||
|
bArr2 = new byte[byteArray2.length << 1];
|
||
|
}
|
||
|
System.arraycopy(byteArray, 0, bArr2, (bArr2.length / 2) - byteArray.length, byteArray.length);
|
||
|
System.arraycopy(byteArray2, 0, bArr2, bArr2.length - byteArray2.length, byteArray2.length);
|
||
|
return bArr2;
|
||
|
} catch (Throwable th) {
|
||
|
aSN1InputStream.close();
|
||
|
throw th;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static byte[] e(String str, byte[] bArr) throws SignatureException {
|
||
|
if (!str.toUpperCase(Locale.getDefault()).contains("ECDSA")) {
|
||
|
return bArr;
|
||
|
}
|
||
|
int length = bArr.length / 2;
|
||
|
byte[] bArr2 = new byte[length];
|
||
|
int length2 = bArr.length / 2;
|
||
|
byte[] bArr3 = new byte[length2];
|
||
|
System.arraycopy(bArr, 0, bArr2, 0, length);
|
||
|
System.arraycopy(bArr, length, bArr3, 0, length2);
|
||
|
BigInteger bigInteger = new BigInteger(1, bArr2);
|
||
|
BigInteger bigInteger2 = new BigInteger(1, bArr3);
|
||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||
|
DEROutputStream dEROutputStream = new DEROutputStream(byteArrayOutputStream);
|
||
|
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
|
||
|
aSN1EncodableVector.add(new ASN1Integer(bigInteger));
|
||
|
aSN1EncodableVector.add(new ASN1Integer(bigInteger2));
|
||
|
try {
|
||
|
dEROutputStream.writeObject(new DERSequence(aSN1EncodableVector));
|
||
|
return byteArrayOutputStream.toByteArray();
|
||
|
} catch (IOException e) {
|
||
|
throw new SignatureException(e);
|
||
|
}
|
||
|
}
|
||
|
}
|