125 lines
4.3 KiB
Java
125 lines
4.3 KiB
Java
package org.bouncycastle.asn1.x9;
|
|
|
|
import java.math.BigInteger;
|
|
import java.util.Enumeration;
|
|
import org.bouncycastle.asn1.ASN1Encodable;
|
|
import org.bouncycastle.asn1.ASN1EncodableVector;
|
|
import org.bouncycastle.asn1.ASN1Integer;
|
|
import org.bouncycastle.asn1.ASN1Object;
|
|
import org.bouncycastle.asn1.ASN1Primitive;
|
|
import org.bouncycastle.asn1.ASN1Sequence;
|
|
import org.bouncycastle.asn1.ASN1TaggedObject;
|
|
import org.bouncycastle.asn1.DERSequence;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class DomainParameters extends ASN1Object {
|
|
private final ASN1Integer g;
|
|
private final ASN1Integer j;
|
|
private final ASN1Integer p;
|
|
private final ASN1Integer q;
|
|
private final ValidationParams validationParams;
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
|
|
public ASN1Primitive toASN1Primitive() {
|
|
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
|
|
aSN1EncodableVector.add(this.p);
|
|
aSN1EncodableVector.add(this.g);
|
|
aSN1EncodableVector.add(this.q);
|
|
ASN1Integer aSN1Integer = this.j;
|
|
if (aSN1Integer != null) {
|
|
aSN1EncodableVector.add(aSN1Integer);
|
|
}
|
|
ValidationParams validationParams = this.validationParams;
|
|
if (validationParams != null) {
|
|
aSN1EncodableVector.add(validationParams);
|
|
}
|
|
return new DERSequence(aSN1EncodableVector);
|
|
}
|
|
|
|
public ValidationParams getValidationParams() {
|
|
return this.validationParams;
|
|
}
|
|
|
|
public BigInteger getQ() {
|
|
return this.q.getPositiveValue();
|
|
}
|
|
|
|
public BigInteger getP() {
|
|
return this.p.getPositiveValue();
|
|
}
|
|
|
|
public BigInteger getJ() {
|
|
ASN1Integer aSN1Integer = this.j;
|
|
if (aSN1Integer == null) {
|
|
return null;
|
|
}
|
|
return aSN1Integer.getPositiveValue();
|
|
}
|
|
|
|
public BigInteger getG() {
|
|
return this.g.getPositiveValue();
|
|
}
|
|
|
|
private static ASN1Encodable getNext(Enumeration enumeration) {
|
|
if (enumeration.hasMoreElements()) {
|
|
return (ASN1Encodable) enumeration.nextElement();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static DomainParameters getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) {
|
|
return getInstance(ASN1Sequence.getInstance(aSN1TaggedObject, z));
|
|
}
|
|
|
|
public static DomainParameters getInstance(Object obj) {
|
|
if (obj instanceof DomainParameters) {
|
|
return (DomainParameters) obj;
|
|
}
|
|
if (obj != null) {
|
|
return new DomainParameters(ASN1Sequence.getInstance(obj));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private DomainParameters(ASN1Sequence aSN1Sequence) {
|
|
if (aSN1Sequence.size() < 3 || aSN1Sequence.size() > 5) {
|
|
StringBuilder sb = new StringBuilder("Bad sequence size: ");
|
|
sb.append(aSN1Sequence.size());
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
Enumeration objects = aSN1Sequence.getObjects();
|
|
this.p = ASN1Integer.getInstance(objects.nextElement());
|
|
this.g = ASN1Integer.getInstance(objects.nextElement());
|
|
this.q = ASN1Integer.getInstance(objects.nextElement());
|
|
ASN1Encodable next = getNext(objects);
|
|
if (next == null || !(next instanceof ASN1Integer)) {
|
|
this.j = null;
|
|
} else {
|
|
this.j = ASN1Integer.getInstance(next);
|
|
next = getNext(objects);
|
|
}
|
|
if (next != null) {
|
|
this.validationParams = ValidationParams.getInstance(next.toASN1Primitive());
|
|
} else {
|
|
this.validationParams = null;
|
|
}
|
|
}
|
|
|
|
public DomainParameters(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3, BigInteger bigInteger4, ValidationParams validationParams) {
|
|
if (bigInteger == null) {
|
|
throw new IllegalArgumentException("'p' cannot be null");
|
|
}
|
|
if (bigInteger2 == null) {
|
|
throw new IllegalArgumentException("'g' cannot be null");
|
|
}
|
|
if (bigInteger3 == null) {
|
|
throw new IllegalArgumentException("'q' cannot be null");
|
|
}
|
|
this.p = new ASN1Integer(bigInteger);
|
|
this.g = new ASN1Integer(bigInteger2);
|
|
this.q = new ASN1Integer(bigInteger3);
|
|
this.j = bigInteger4 != null ? new ASN1Integer(bigInteger4) : null;
|
|
this.validationParams = validationParams;
|
|
}
|
|
}
|