67 lines
2.9 KiB
Java
67 lines
2.9 KiB
Java
|
package org.bouncycastle.jce.spec;
|
||
|
|
||
|
import java.math.BigInteger;
|
||
|
import java.security.spec.ECField;
|
||
|
import java.security.spec.ECFieldF2m;
|
||
|
import java.security.spec.ECFieldFp;
|
||
|
import java.security.spec.ECPoint;
|
||
|
import java.security.spec.EllipticCurve;
|
||
|
import org.bouncycastle.math.ec.ECAlgorithms;
|
||
|
import org.bouncycastle.math.ec.ECCurve;
|
||
|
import org.bouncycastle.math.field.FiniteField;
|
||
|
import org.bouncycastle.math.field.Polynomial;
|
||
|
import org.bouncycastle.math.field.PolynomialExtensionField;
|
||
|
import org.bouncycastle.util.Arrays;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class ECNamedCurveSpec extends java.security.spec.ECParameterSpec {
|
||
|
private String name;
|
||
|
|
||
|
public String getName() {
|
||
|
return this.name;
|
||
|
}
|
||
|
|
||
|
private static ECPoint convertPoint(org.bouncycastle.math.ec.ECPoint eCPoint) {
|
||
|
org.bouncycastle.math.ec.ECPoint normalize = eCPoint.normalize();
|
||
|
return new ECPoint(normalize.getAffineXCoord().toBigInteger(), normalize.getAffineYCoord().toBigInteger());
|
||
|
}
|
||
|
|
||
|
private static ECField convertField(FiniteField finiteField) {
|
||
|
if (ECAlgorithms.isFpField(finiteField)) {
|
||
|
return new ECFieldFp(finiteField.getCharacteristic());
|
||
|
}
|
||
|
Polynomial minimalPolynomial = ((PolynomialExtensionField) finiteField).getMinimalPolynomial();
|
||
|
int[] exponentsPresent = minimalPolynomial.getExponentsPresent();
|
||
|
return new ECFieldF2m(minimalPolynomial.getDegree(), Arrays.reverse(Arrays.copyOfRange(exponentsPresent, 1, exponentsPresent.length - 1)));
|
||
|
}
|
||
|
|
||
|
private static EllipticCurve convertCurve(ECCurve eCCurve, byte[] bArr) {
|
||
|
return new EllipticCurve(convertField(eCCurve.getField()), eCCurve.getA().toBigInteger(), eCCurve.getB().toBigInteger(), bArr);
|
||
|
}
|
||
|
|
||
|
public ECNamedCurveSpec(String str, ECCurve eCCurve, org.bouncycastle.math.ec.ECPoint eCPoint, BigInteger bigInteger, BigInteger bigInteger2, byte[] bArr) {
|
||
|
super(convertCurve(eCCurve, bArr), convertPoint(eCPoint), bigInteger, bigInteger2.intValue());
|
||
|
this.name = str;
|
||
|
}
|
||
|
|
||
|
public ECNamedCurveSpec(String str, ECCurve eCCurve, org.bouncycastle.math.ec.ECPoint eCPoint, BigInteger bigInteger, BigInteger bigInteger2) {
|
||
|
super(convertCurve(eCCurve, null), convertPoint(eCPoint), bigInteger, bigInteger2.intValue());
|
||
|
this.name = str;
|
||
|
}
|
||
|
|
||
|
public ECNamedCurveSpec(String str, ECCurve eCCurve, org.bouncycastle.math.ec.ECPoint eCPoint, BigInteger bigInteger) {
|
||
|
super(convertCurve(eCCurve, null), convertPoint(eCPoint), bigInteger, 1);
|
||
|
this.name = str;
|
||
|
}
|
||
|
|
||
|
public ECNamedCurveSpec(String str, EllipticCurve ellipticCurve, ECPoint eCPoint, BigInteger bigInteger, BigInteger bigInteger2) {
|
||
|
super(ellipticCurve, eCPoint, bigInteger, bigInteger2.intValue());
|
||
|
this.name = str;
|
||
|
}
|
||
|
|
||
|
public ECNamedCurveSpec(String str, EllipticCurve ellipticCurve, ECPoint eCPoint, BigInteger bigInteger) {
|
||
|
super(ellipticCurve, eCPoint, bigInteger, 1);
|
||
|
this.name = str;
|
||
|
}
|
||
|
}
|