what-the-bank/sources/org/bouncycastle/asn1/x9/X9Curve.java

157 lines
7.0 KiB
Java

package org.bouncycastle.asn1.x9;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.math.ec.ECAlgorithms;
import org.bouncycastle.math.ec.ECCurve;
/* loaded from: classes6.dex */
public class X9Curve extends ASN1Object implements X9ObjectIdentifiers {
private ECCurve curve;
private ASN1ObjectIdentifier fieldIdentifier;
private byte[] seed;
/* JADX WARN: Removed duplicated region for block: B:7:0x005f */
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public org.bouncycastle.asn1.ASN1Primitive toASN1Primitive() {
/*
r3 = this;
org.bouncycastle.asn1.ASN1EncodableVector r0 = new org.bouncycastle.asn1.ASN1EncodableVector
r0.<init>()
org.bouncycastle.asn1.ASN1ObjectIdentifier r1 = r3.fieldIdentifier
org.bouncycastle.asn1.ASN1ObjectIdentifier r2 = org.bouncycastle.asn1.x9.X9Curve.prime_field
boolean r1 = r1.equals(r2)
if (r1 == 0) goto L2d
org.bouncycastle.asn1.x9.X9FieldElement r1 = new org.bouncycastle.asn1.x9.X9FieldElement
org.bouncycastle.math.ec.ECCurve r2 = r3.curve
org.bouncycastle.math.ec.ECFieldElement r2 = r2.getA()
r1.<init>(r2)
org.bouncycastle.asn1.ASN1Primitive r1 = r1.toASN1Primitive()
r0.add(r1)
org.bouncycastle.asn1.x9.X9FieldElement r1 = new org.bouncycastle.asn1.x9.X9FieldElement
org.bouncycastle.math.ec.ECCurve r2 = r3.curve
org.bouncycastle.math.ec.ECFieldElement r2 = r2.getB()
r1.<init>(r2)
goto L54
L2d:
org.bouncycastle.asn1.ASN1ObjectIdentifier r1 = r3.fieldIdentifier
org.bouncycastle.asn1.ASN1ObjectIdentifier r2 = org.bouncycastle.asn1.x9.X9Curve.characteristic_two_field
boolean r1 = r1.equals(r2)
if (r1 == 0) goto L5b
org.bouncycastle.asn1.x9.X9FieldElement r1 = new org.bouncycastle.asn1.x9.X9FieldElement
org.bouncycastle.math.ec.ECCurve r2 = r3.curve
org.bouncycastle.math.ec.ECFieldElement r2 = r2.getA()
r1.<init>(r2)
org.bouncycastle.asn1.ASN1Primitive r1 = r1.toASN1Primitive()
r0.add(r1)
org.bouncycastle.asn1.x9.X9FieldElement r1 = new org.bouncycastle.asn1.x9.X9FieldElement
org.bouncycastle.math.ec.ECCurve r2 = r3.curve
org.bouncycastle.math.ec.ECFieldElement r2 = r2.getB()
r1.<init>(r2)
L54:
org.bouncycastle.asn1.ASN1Primitive r1 = r1.toASN1Primitive()
r0.add(r1)
L5b:
byte[] r1 = r3.seed
if (r1 == 0) goto L69
org.bouncycastle.asn1.DERBitString r1 = new org.bouncycastle.asn1.DERBitString
byte[] r2 = r3.seed
r1.<init>(r2)
r0.add(r1)
L69:
org.bouncycastle.asn1.DERSequence r1 = new org.bouncycastle.asn1.DERSequence
r1.<init>(r0)
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.asn1.x9.X9Curve.toASN1Primitive():org.bouncycastle.asn1.ASN1Primitive");
}
public byte[] getSeed() {
return this.seed;
}
public ECCurve getCurve() {
return this.curve;
}
private void setFieldIdentifier() {
ASN1ObjectIdentifier aSN1ObjectIdentifier;
if (ECAlgorithms.isFpCurve(this.curve)) {
aSN1ObjectIdentifier = prime_field;
} else {
if (!ECAlgorithms.isF2mCurve(this.curve)) {
throw new IllegalArgumentException("This type of ECCurve is not implemented");
}
aSN1ObjectIdentifier = characteristic_two_field;
}
this.fieldIdentifier = aSN1ObjectIdentifier;
}
public X9Curve(ECCurve eCCurve, byte[] bArr) {
this.fieldIdentifier = null;
this.curve = eCCurve;
this.seed = bArr;
setFieldIdentifier();
}
public X9Curve(ECCurve eCCurve) {
this.fieldIdentifier = null;
this.curve = eCCurve;
this.seed = null;
setFieldIdentifier();
}
public X9Curve(X9FieldID x9FieldID, ASN1Sequence aSN1Sequence) {
int intValue;
int i;
int i2;
ECCurve f2m;
this.fieldIdentifier = null;
ASN1ObjectIdentifier identifier = x9FieldID.getIdentifier();
this.fieldIdentifier = identifier;
if (identifier.equals(prime_field)) {
BigInteger value = ((ASN1Integer) x9FieldID.getParameters()).getValue();
f2m = new ECCurve.Fp(value, new X9FieldElement(value, (ASN1OctetString) aSN1Sequence.getObjectAt(0)).getValue().toBigInteger(), new X9FieldElement(value, (ASN1OctetString) aSN1Sequence.getObjectAt(1)).getValue().toBigInteger());
} else {
if (!this.fieldIdentifier.equals(characteristic_two_field)) {
throw new IllegalArgumentException("This type of ECCurve is not implemented");
}
ASN1Sequence aSN1Sequence2 = ASN1Sequence.getInstance(x9FieldID.getParameters());
int intValue2 = ((ASN1Integer) aSN1Sequence2.getObjectAt(0)).getValue().intValue();
ASN1ObjectIdentifier aSN1ObjectIdentifier = (ASN1ObjectIdentifier) aSN1Sequence2.getObjectAt(1);
if (aSN1ObjectIdentifier.equals(tpBasis)) {
i = ASN1Integer.getInstance(aSN1Sequence2.getObjectAt(2)).getValue().intValue();
i2 = 0;
intValue = 0;
} else {
if (!aSN1ObjectIdentifier.equals(ppBasis)) {
throw new IllegalArgumentException("This type of EC basis is not implemented");
}
ASN1Sequence aSN1Sequence3 = ASN1Sequence.getInstance(aSN1Sequence2.getObjectAt(2));
int intValue3 = ASN1Integer.getInstance(aSN1Sequence3.getObjectAt(0)).getValue().intValue();
int intValue4 = ASN1Integer.getInstance(aSN1Sequence3.getObjectAt(1)).getValue().intValue();
intValue = ASN1Integer.getInstance(aSN1Sequence3.getObjectAt(2)).getValue().intValue();
i = intValue3;
i2 = intValue4;
}
int i3 = i;
int i4 = i2;
int i5 = intValue;
f2m = new ECCurve.F2m(intValue2, i3, i4, i5, new X9FieldElement(intValue2, i3, i4, i5, (ASN1OctetString) aSN1Sequence.getObjectAt(0)).getValue().toBigInteger(), new X9FieldElement(intValue2, i3, i4, i5, (ASN1OctetString) aSN1Sequence.getObjectAt(1)).getValue().toBigInteger());
}
this.curve = f2m;
if (aSN1Sequence.size() == 3) {
this.seed = ((DERBitString) aSN1Sequence.getObjectAt(2)).getBytes();
}
}
}