425 lines
22 KiB
Java
425 lines
22 KiB
Java
|
package org.bouncycastle.jcajce.provider.asymmetric.dstu;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.io.ObjectInputStream;
|
||
|
import java.io.ObjectOutputStream;
|
||
|
import java.math.BigInteger;
|
||
|
import java.security.interfaces.ECPrivateKey;
|
||
|
import java.security.spec.ECParameterSpec;
|
||
|
import java.security.spec.ECPoint;
|
||
|
import java.util.Enumeration;
|
||
|
import org.bouncycastle.asn1.ASN1Encodable;
|
||
|
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||
|
import org.bouncycastle.asn1.ASN1Primitive;
|
||
|
import org.bouncycastle.asn1.DERBitString;
|
||
|
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
|
||
|
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
||
|
import org.bouncycastle.crypto.params.ECDomainParameters;
|
||
|
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
||
|
import org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util;
|
||
|
import org.bouncycastle.jcajce.provider.asymmetric.util.PKCS12BagAttributeCarrierImpl;
|
||
|
import org.bouncycastle.jce.interfaces.ECPointEncoder;
|
||
|
import org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier;
|
||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||
|
import org.bouncycastle.jce.spec.ECPrivateKeySpec;
|
||
|
import org.bouncycastle.util.Strings;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class BCDSTU4145PrivateKey implements ECPrivateKey, org.bouncycastle.jce.interfaces.ECPrivateKey, PKCS12BagAttributeCarrier, ECPointEncoder {
|
||
|
static final long serialVersionUID = 7245981689601667138L;
|
||
|
private String algorithm;
|
||
|
private transient PKCS12BagAttributeCarrierImpl attrCarrier;
|
||
|
private transient BigInteger d;
|
||
|
private transient ECParameterSpec ecSpec;
|
||
|
private transient DERBitString publicKey;
|
||
|
private boolean withCompression;
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuffer stringBuffer = new StringBuffer("EC Private Key");
|
||
|
String lineSeparator = Strings.lineSeparator();
|
||
|
stringBuffer.append(lineSeparator);
|
||
|
stringBuffer.append(" S: ").append(this.d.toString(16)).append(lineSeparator);
|
||
|
return stringBuffer.toString();
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.jce.interfaces.ECPointEncoder
|
||
|
public void setPointFormat(String str) {
|
||
|
this.withCompression = !"UNCOMPRESSED".equalsIgnoreCase(str);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier
|
||
|
public void setBagAttribute(ASN1ObjectIdentifier aSN1ObjectIdentifier, ASN1Encodable aSN1Encodable) {
|
||
|
this.attrCarrier.setBagAttribute(aSN1ObjectIdentifier, aSN1Encodable);
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
return getD().hashCode() ^ engineGetSpec().hashCode();
|
||
|
}
|
||
|
|
||
|
@Override // java.security.interfaces.ECPrivateKey
|
||
|
public BigInteger getS() {
|
||
|
return this.d;
|
||
|
}
|
||
|
|
||
|
@Override // java.security.interfaces.ECKey
|
||
|
public ECParameterSpec getParams() {
|
||
|
return this.ecSpec;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.jce.interfaces.ECKey
|
||
|
public org.bouncycastle.jce.spec.ECParameterSpec getParameters() {
|
||
|
ECParameterSpec eCParameterSpec = this.ecSpec;
|
||
|
if (eCParameterSpec == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return EC5Util.convertSpec(eCParameterSpec, this.withCompression);
|
||
|
}
|
||
|
|
||
|
@Override // java.security.Key
|
||
|
public String getFormat() {
|
||
|
return "PKCS#8";
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:10:0x0087 */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:14:0x00a6 A[Catch: IOException -> 0x00d7, TryCatch #0 {IOException -> 0x00d7, blocks: (B:12:0x009c, B:14:0x00a6, B:15:0x00d0, B:19:0x00bb), top: B:11:0x009c }] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:19:0x00bb A[Catch: IOException -> 0x00d7, TryCatch #0 {IOException -> 0x00d7, blocks: (B:12:0x009c, B:14:0x00a6, B:15:0x00d0, B:19:0x00bb), top: B:11:0x009c }] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:21:0x0093 */
|
||
|
@Override // java.security.Key
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public byte[] getEncoded() {
|
||
|
/*
|
||
|
r10 = this;
|
||
|
java.security.spec.ECParameterSpec r0 = r10.ecSpec
|
||
|
boolean r1 = r0 instanceof org.bouncycastle.jce.spec.ECNamedCurveSpec
|
||
|
r2 = 0
|
||
|
if (r1 == 0) goto L26
|
||
|
org.bouncycastle.jce.spec.ECNamedCurveSpec r0 = (org.bouncycastle.jce.spec.ECNamedCurveSpec) r0
|
||
|
java.lang.String r0 = r0.getName()
|
||
|
org.bouncycastle.asn1.ASN1ObjectIdentifier r0 = org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil.getNamedCurveOid(r0)
|
||
|
if (r0 != 0) goto L20
|
||
|
org.bouncycastle.asn1.ASN1ObjectIdentifier r0 = new org.bouncycastle.asn1.ASN1ObjectIdentifier
|
||
|
java.security.spec.ECParameterSpec r1 = r10.ecSpec
|
||
|
org.bouncycastle.jce.spec.ECNamedCurveSpec r1 = (org.bouncycastle.jce.spec.ECNamedCurveSpec) r1
|
||
|
java.lang.String r1 = r1.getName()
|
||
|
r0.<init>(r1)
|
||
|
L20:
|
||
|
org.bouncycastle.asn1.x9.X962Parameters r1 = new org.bouncycastle.asn1.x9.X962Parameters
|
||
|
r1.<init>(r0)
|
||
|
goto L72
|
||
|
L26:
|
||
|
if (r0 != 0) goto L38
|
||
|
org.bouncycastle.asn1.x9.X962Parameters r0 = new org.bouncycastle.asn1.x9.X962Parameters
|
||
|
org.bouncycastle.asn1.DERNull r1 = org.bouncycastle.asn1.DERNull.INSTANCE
|
||
|
r0.<init>(r1)
|
||
|
java.math.BigInteger r1 = r10.getS()
|
||
|
int r1 = org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil.getOrderBitLength(r2, r1)
|
||
|
goto L83
|
||
|
L38:
|
||
|
java.security.spec.EllipticCurve r0 = r0.getCurve()
|
||
|
org.bouncycastle.math.ec.ECCurve r4 = org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util.convertCurve(r0)
|
||
|
org.bouncycastle.asn1.x9.X962Parameters r1 = new org.bouncycastle.asn1.x9.X962Parameters
|
||
|
org.bouncycastle.asn1.x9.X9ECParameters r0 = new org.bouncycastle.asn1.x9.X9ECParameters
|
||
|
java.security.spec.ECParameterSpec r3 = r10.ecSpec
|
||
|
java.security.spec.ECPoint r3 = r3.getGenerator()
|
||
|
boolean r5 = r10.withCompression
|
||
|
org.bouncycastle.math.ec.ECPoint r5 = org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util.convertPoint(r4, r3, r5)
|
||
|
java.security.spec.ECParameterSpec r3 = r10.ecSpec
|
||
|
java.math.BigInteger r6 = r3.getOrder()
|
||
|
java.security.spec.ECParameterSpec r3 = r10.ecSpec
|
||
|
int r3 = r3.getCofactor()
|
||
|
long r7 = (long) r3
|
||
|
java.math.BigInteger r7 = java.math.BigInteger.valueOf(r7)
|
||
|
java.security.spec.ECParameterSpec r3 = r10.ecSpec
|
||
|
java.security.spec.EllipticCurve r3 = r3.getCurve()
|
||
|
byte[] r8 = r3.getSeed()
|
||
|
r3 = r0
|
||
|
r3.<init>(r4, r5, r6, r7, r8)
|
||
|
r1.<init>(r0)
|
||
|
L72:
|
||
|
java.security.spec.ECParameterSpec r0 = r10.ecSpec
|
||
|
java.math.BigInteger r0 = r0.getOrder()
|
||
|
java.math.BigInteger r3 = r10.getS()
|
||
|
int r0 = org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil.getOrderBitLength(r0, r3)
|
||
|
r9 = r1
|
||
|
r1 = r0
|
||
|
r0 = r9
|
||
|
L83:
|
||
|
org.bouncycastle.asn1.DERBitString r3 = r10.publicKey
|
||
|
if (r3 == 0) goto L93
|
||
|
org.bouncycastle.asn1.sec.ECPrivateKey r3 = new org.bouncycastle.asn1.sec.ECPrivateKey
|
||
|
java.math.BigInteger r4 = r10.getS()
|
||
|
org.bouncycastle.asn1.DERBitString r5 = r10.publicKey
|
||
|
r3.<init>(r1, r4, r5, r0)
|
||
|
goto L9c
|
||
|
L93:
|
||
|
org.bouncycastle.asn1.sec.ECPrivateKey r3 = new org.bouncycastle.asn1.sec.ECPrivateKey
|
||
|
java.math.BigInteger r4 = r10.getS()
|
||
|
r3.<init>(r1, r4, r0)
|
||
|
L9c:
|
||
|
java.lang.String r1 = r10.algorithm // Catch: java.io.IOException -> Ld7
|
||
|
java.lang.String r4 = "DSTU4145"
|
||
|
boolean r1 = r1.equals(r4) // Catch: java.io.IOException -> Ld7
|
||
|
if (r1 == 0) goto Lbb
|
||
|
org.bouncycastle.asn1.pkcs.PrivateKeyInfo r1 = new org.bouncycastle.asn1.pkcs.PrivateKeyInfo // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.x509.AlgorithmIdentifier r4 = new org.bouncycastle.asn1.x509.AlgorithmIdentifier // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.ASN1ObjectIdentifier r5 = org.bouncycastle.asn1.ua.UAObjectIdentifiers.dstu4145be // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.ASN1Primitive r0 = r0.toASN1Primitive() // Catch: java.io.IOException -> Ld7
|
||
|
r4.<init>(r5, r0) // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.ASN1Primitive r0 = r3.toASN1Primitive() // Catch: java.io.IOException -> Ld7
|
||
|
r1.<init>(r4, r0) // Catch: java.io.IOException -> Ld7
|
||
|
goto Ld0
|
||
|
Lbb:
|
||
|
org.bouncycastle.asn1.x509.AlgorithmIdentifier r1 = new org.bouncycastle.asn1.x509.AlgorithmIdentifier // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.ASN1ObjectIdentifier r4 = org.bouncycastle.asn1.x9.X9ObjectIdentifiers.id_ecPublicKey // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.ASN1Primitive r0 = r0.toASN1Primitive() // Catch: java.io.IOException -> Ld7
|
||
|
r1.<init>(r4, r0) // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.pkcs.PrivateKeyInfo r0 = new org.bouncycastle.asn1.pkcs.PrivateKeyInfo // Catch: java.io.IOException -> Ld7
|
||
|
org.bouncycastle.asn1.ASN1Primitive r3 = r3.toASN1Primitive() // Catch: java.io.IOException -> Ld7
|
||
|
r0.<init>(r1, r3) // Catch: java.io.IOException -> Ld7
|
||
|
r1 = r0
|
||
|
Ld0:
|
||
|
java.lang.String r0 = "DER"
|
||
|
byte[] r0 = r1.getEncoded(r0) // Catch: java.io.IOException -> Ld7
|
||
|
return r0
|
||
|
Ld7:
|
||
|
return r2
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.jcajce.provider.asymmetric.dstu.BCDSTU4145PrivateKey.getEncoded():byte[]");
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.jce.interfaces.ECPrivateKey
|
||
|
public BigInteger getD() {
|
||
|
return this.d;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier
|
||
|
public Enumeration getBagAttributeKeys() {
|
||
|
return this.attrCarrier.getBagAttributeKeys();
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier
|
||
|
public ASN1Encodable getBagAttribute(ASN1ObjectIdentifier aSN1ObjectIdentifier) {
|
||
|
return this.attrCarrier.getBagAttribute(aSN1ObjectIdentifier);
|
||
|
}
|
||
|
|
||
|
@Override // java.security.Key
|
||
|
public String getAlgorithm() {
|
||
|
return this.algorithm;
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (!(obj instanceof BCDSTU4145PrivateKey)) {
|
||
|
return false;
|
||
|
}
|
||
|
BCDSTU4145PrivateKey bCDSTU4145PrivateKey = (BCDSTU4145PrivateKey) obj;
|
||
|
return getD().equals(bCDSTU4145PrivateKey.getD()) && engineGetSpec().equals(bCDSTU4145PrivateKey.engineGetSpec());
|
||
|
}
|
||
|
|
||
|
org.bouncycastle.jce.spec.ECParameterSpec engineGetSpec() {
|
||
|
ECParameterSpec eCParameterSpec = this.ecSpec;
|
||
|
return eCParameterSpec != null ? EC5Util.convertSpec(eCParameterSpec, this.withCompression) : BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
|
||
|
}
|
||
|
|
||
|
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
|
||
|
objectOutputStream.defaultWriteObject();
|
||
|
objectOutputStream.writeObject(getEncoded());
|
||
|
}
|
||
|
|
||
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||
|
objectInputStream.defaultReadObject();
|
||
|
populateFromPrivKeyInfo(PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray((byte[]) objectInputStream.readObject())));
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:12:0x0101 */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:9:0x00f6 */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
private void populateFromPrivKeyInfo(org.bouncycastle.asn1.pkcs.PrivateKeyInfo r11) throws java.io.IOException {
|
||
|
/*
|
||
|
r10 = this;
|
||
|
org.bouncycastle.asn1.x9.X962Parameters r0 = new org.bouncycastle.asn1.x9.X962Parameters
|
||
|
org.bouncycastle.asn1.x509.AlgorithmIdentifier r1 = r11.getPrivateKeyAlgorithm()
|
||
|
org.bouncycastle.asn1.ASN1Encodable r1 = r1.getParameters()
|
||
|
org.bouncycastle.asn1.ASN1Primitive r1 = (org.bouncycastle.asn1.ASN1Primitive) r1
|
||
|
r0.<init>(r1)
|
||
|
boolean r1 = r0.isNamedCurve()
|
||
|
if (r1 == 0) goto La0
|
||
|
org.bouncycastle.asn1.ASN1Primitive r0 = r0.getParameters()
|
||
|
org.bouncycastle.asn1.ASN1ObjectIdentifier r0 = org.bouncycastle.asn1.ASN1ObjectIdentifier.getInstance(r0)
|
||
|
org.bouncycastle.asn1.x9.X9ECParameters r1 = org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil.getNamedCurveByOid(r0)
|
||
|
if (r1 != 0) goto L64
|
||
|
org.bouncycastle.crypto.params.ECDomainParameters r1 = org.bouncycastle.asn1.ua.DSTU4145NamedCurves.getByOID(r0)
|
||
|
org.bouncycastle.math.ec.ECCurve r2 = r1.getCurve()
|
||
|
byte[] r3 = r1.getSeed()
|
||
|
java.security.spec.EllipticCurve r6 = org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util.convertCurve(r2, r3)
|
||
|
org.bouncycastle.jce.spec.ECNamedCurveSpec r2 = new org.bouncycastle.jce.spec.ECNamedCurveSpec
|
||
|
java.lang.String r5 = r0.getId()
|
||
|
java.security.spec.ECPoint r7 = new java.security.spec.ECPoint
|
||
|
org.bouncycastle.math.ec.ECPoint r0 = r1.getG()
|
||
|
org.bouncycastle.math.ec.ECFieldElement r0 = r0.getAffineXCoord()
|
||
|
java.math.BigInteger r0 = r0.toBigInteger()
|
||
|
org.bouncycastle.math.ec.ECPoint r3 = r1.getG()
|
||
|
org.bouncycastle.math.ec.ECFieldElement r3 = r3.getAffineYCoord()
|
||
|
java.math.BigInteger r3 = r3.toBigInteger()
|
||
|
r7.<init>(r0, r3)
|
||
|
java.math.BigInteger r8 = r1.getN()
|
||
|
java.math.BigInteger r9 = r1.getH()
|
||
|
r4 = r2
|
||
|
r4.<init>(r5, r6, r7, r8, r9)
|
||
|
goto Lec
|
||
|
L64:
|
||
|
org.bouncycastle.math.ec.ECCurve r2 = r1.getCurve()
|
||
|
byte[] r3 = r1.getSeed()
|
||
|
java.security.spec.EllipticCurve r6 = org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util.convertCurve(r2, r3)
|
||
|
org.bouncycastle.jce.spec.ECNamedCurveSpec r2 = new org.bouncycastle.jce.spec.ECNamedCurveSpec
|
||
|
java.lang.String r5 = org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil.getCurveName(r0)
|
||
|
java.security.spec.ECPoint r7 = new java.security.spec.ECPoint
|
||
|
org.bouncycastle.math.ec.ECPoint r0 = r1.getG()
|
||
|
org.bouncycastle.math.ec.ECFieldElement r0 = r0.getAffineXCoord()
|
||
|
java.math.BigInteger r0 = r0.toBigInteger()
|
||
|
org.bouncycastle.math.ec.ECPoint r3 = r1.getG()
|
||
|
org.bouncycastle.math.ec.ECFieldElement r3 = r3.getAffineYCoord()
|
||
|
java.math.BigInteger r3 = r3.toBigInteger()
|
||
|
r7.<init>(r0, r3)
|
||
|
java.math.BigInteger r8 = r1.getN()
|
||
|
java.math.BigInteger r9 = r1.getH()
|
||
|
r4 = r2
|
||
|
r4.<init>(r5, r6, r7, r8, r9)
|
||
|
goto Lec
|
||
|
La0:
|
||
|
boolean r1 = r0.isImplicitlyCA()
|
||
|
if (r1 == 0) goto Laa
|
||
|
r0 = 0
|
||
|
r10.ecSpec = r0
|
||
|
goto Lee
|
||
|
Laa:
|
||
|
org.bouncycastle.asn1.ASN1Primitive r0 = r0.getParameters()
|
||
|
org.bouncycastle.asn1.x9.X9ECParameters r0 = org.bouncycastle.asn1.x9.X9ECParameters.getInstance(r0)
|
||
|
java.security.spec.ECParameterSpec r2 = new java.security.spec.ECParameterSpec
|
||
|
org.bouncycastle.math.ec.ECCurve r1 = r0.getCurve()
|
||
|
byte[] r3 = r0.getSeed()
|
||
|
java.security.spec.EllipticCurve r1 = org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util.convertCurve(r1, r3)
|
||
|
java.security.spec.ECPoint r3 = new java.security.spec.ECPoint
|
||
|
org.bouncycastle.math.ec.ECPoint r4 = r0.getG()
|
||
|
org.bouncycastle.math.ec.ECFieldElement r4 = r4.getAffineXCoord()
|
||
|
java.math.BigInteger r4 = r4.toBigInteger()
|
||
|
org.bouncycastle.math.ec.ECPoint r5 = r0.getG()
|
||
|
org.bouncycastle.math.ec.ECFieldElement r5 = r5.getAffineYCoord()
|
||
|
java.math.BigInteger r5 = r5.toBigInteger()
|
||
|
r3.<init>(r4, r5)
|
||
|
java.math.BigInteger r4 = r0.getN()
|
||
|
java.math.BigInteger r0 = r0.getH()
|
||
|
int r0 = r0.intValue()
|
||
|
r2.<init>(r1, r3, r4, r0)
|
||
|
Lec:
|
||
|
r10.ecSpec = r2
|
||
|
Lee:
|
||
|
org.bouncycastle.asn1.ASN1Encodable r11 = r11.parsePrivateKey()
|
||
|
boolean r0 = r11 instanceof org.bouncycastle.asn1.ASN1Integer
|
||
|
if (r0 == 0) goto L101
|
||
|
org.bouncycastle.asn1.ASN1Integer r11 = org.bouncycastle.asn1.ASN1Integer.getInstance(r11)
|
||
|
java.math.BigInteger r11 = r11.getValue()
|
||
|
r10.d = r11
|
||
|
return
|
||
|
L101:
|
||
|
org.bouncycastle.asn1.sec.ECPrivateKey r11 = org.bouncycastle.asn1.sec.ECPrivateKey.getInstance(r11)
|
||
|
java.math.BigInteger r0 = r11.getKey()
|
||
|
r10.d = r0
|
||
|
org.bouncycastle.asn1.DERBitString r11 = r11.getPublicKey()
|
||
|
r10.publicKey = r11
|
||
|
return
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.jcajce.provider.asymmetric.dstu.BCDSTU4145PrivateKey.populateFromPrivKeyInfo(org.bouncycastle.asn1.pkcs.PrivateKeyInfo):void");
|
||
|
}
|
||
|
|
||
|
private DERBitString getPublicKeyDetails(BCDSTU4145PublicKey bCDSTU4145PublicKey) {
|
||
|
try {
|
||
|
return SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(bCDSTU4145PublicKey.getEncoded())).getPublicKeyData();
|
||
|
} catch (IOException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public BCDSTU4145PrivateKey(ECPrivateKeySpec eCPrivateKeySpec) {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
this.d = eCPrivateKeySpec.getD();
|
||
|
this.ecSpec = eCPrivateKeySpec.getParams() != null ? EC5Util.convertSpec(EC5Util.convertCurve(eCPrivateKeySpec.getParams().getCurve(), eCPrivateKeySpec.getParams().getSeed()), eCPrivateKeySpec.getParams()) : null;
|
||
|
}
|
||
|
|
||
|
public BCDSTU4145PrivateKey(BCDSTU4145PrivateKey bCDSTU4145PrivateKey) {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
this.d = bCDSTU4145PrivateKey.d;
|
||
|
this.ecSpec = bCDSTU4145PrivateKey.ecSpec;
|
||
|
this.withCompression = bCDSTU4145PrivateKey.withCompression;
|
||
|
this.attrCarrier = bCDSTU4145PrivateKey.attrCarrier;
|
||
|
this.publicKey = bCDSTU4145PrivateKey.publicKey;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public BCDSTU4145PrivateKey(PrivateKeyInfo privateKeyInfo) throws IOException {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
populateFromPrivKeyInfo(privateKeyInfo);
|
||
|
}
|
||
|
|
||
|
public BCDSTU4145PrivateKey(java.security.spec.ECPrivateKeySpec eCPrivateKeySpec) {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
this.d = eCPrivateKeySpec.getS();
|
||
|
this.ecSpec = eCPrivateKeySpec.getParams();
|
||
|
}
|
||
|
|
||
|
public BCDSTU4145PrivateKey(ECPrivateKey eCPrivateKey) {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
this.d = eCPrivateKey.getS();
|
||
|
this.algorithm = eCPrivateKey.getAlgorithm();
|
||
|
this.ecSpec = eCPrivateKey.getParams();
|
||
|
}
|
||
|
|
||
|
public BCDSTU4145PrivateKey(String str, ECPrivateKeyParameters eCPrivateKeyParameters, BCDSTU4145PublicKey bCDSTU4145PublicKey, org.bouncycastle.jce.spec.ECParameterSpec eCParameterSpec) {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
ECDomainParameters parameters = eCPrivateKeyParameters.getParameters();
|
||
|
this.algorithm = str;
|
||
|
this.d = eCPrivateKeyParameters.getD();
|
||
|
this.ecSpec = eCParameterSpec == null ? new ECParameterSpec(EC5Util.convertCurve(parameters.getCurve(), parameters.getSeed()), new ECPoint(parameters.getG().getAffineXCoord().toBigInteger(), parameters.getG().getAffineYCoord().toBigInteger()), parameters.getN(), parameters.getH().intValue()) : new ECParameterSpec(EC5Util.convertCurve(eCParameterSpec.getCurve(), eCParameterSpec.getSeed()), new ECPoint(eCParameterSpec.getG().getAffineXCoord().toBigInteger(), eCParameterSpec.getG().getAffineYCoord().toBigInteger()), eCParameterSpec.getN(), eCParameterSpec.getH().intValue());
|
||
|
this.publicKey = getPublicKeyDetails(bCDSTU4145PublicKey);
|
||
|
}
|
||
|
|
||
|
public BCDSTU4145PrivateKey(String str, ECPrivateKeyParameters eCPrivateKeyParameters, BCDSTU4145PublicKey bCDSTU4145PublicKey, ECParameterSpec eCParameterSpec) {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
ECDomainParameters parameters = eCPrivateKeyParameters.getParameters();
|
||
|
this.algorithm = str;
|
||
|
this.d = eCPrivateKeyParameters.getD();
|
||
|
if (eCParameterSpec == null) {
|
||
|
this.ecSpec = new ECParameterSpec(EC5Util.convertCurve(parameters.getCurve(), parameters.getSeed()), new ECPoint(parameters.getG().getAffineXCoord().toBigInteger(), parameters.getG().getAffineYCoord().toBigInteger()), parameters.getN(), parameters.getH().intValue());
|
||
|
} else {
|
||
|
this.ecSpec = eCParameterSpec;
|
||
|
}
|
||
|
this.publicKey = getPublicKeyDetails(bCDSTU4145PublicKey);
|
||
|
}
|
||
|
|
||
|
public BCDSTU4145PrivateKey(String str, ECPrivateKeyParameters eCPrivateKeyParameters) {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
this.algorithm = str;
|
||
|
this.d = eCPrivateKeyParameters.getD();
|
||
|
this.ecSpec = null;
|
||
|
}
|
||
|
|
||
|
protected BCDSTU4145PrivateKey() {
|
||
|
this.algorithm = "DSTU4145";
|
||
|
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
|
||
|
}
|
||
|
}
|