what-the-bank/sources/org/bouncycastle/crypto/params/DHParameters.java

109 lines
3.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.params;
import java.math.BigInteger;
import org.bouncycastle.crypto.CipherParameters;
/* loaded from: classes6.dex */
public class DHParameters implements CipherParameters {
private static final int DEFAULT_MINIMUM_LENGTH = 160;
private BigInteger g;
private BigInteger j;
private int l;
private int m;
private BigInteger p;
private BigInteger q;
private DHValidationParameters validation;
private static int getDefaultMParam(int i) {
if (i != 0 && i < 160) {
return i;
}
return 160;
}
public int hashCode() {
return (getP().hashCode() ^ getG().hashCode()) ^ (getQ() != null ? getQ().hashCode() : 0);
}
public DHValidationParameters getValidationParameters() {
return this.validation;
}
public BigInteger getQ() {
return this.q;
}
public BigInteger getP() {
return this.p;
}
public int getM() {
return this.m;
}
public int getL() {
return this.l;
}
public BigInteger getJ() {
return this.j;
}
public BigInteger getG() {
return this.g;
}
public boolean equals(Object obj) {
if (!(obj instanceof DHParameters)) {
return false;
}
DHParameters dHParameters = (DHParameters) obj;
if (getQ() != null) {
if (!getQ().equals(dHParameters.getQ())) {
return false;
}
} else if (dHParameters.getQ() != null) {
return false;
}
return dHParameters.getP().equals(this.p) && dHParameters.getG().equals(this.g);
}
public DHParameters(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3, BigInteger bigInteger4, DHValidationParameters dHValidationParameters) {
this(bigInteger, bigInteger2, bigInteger3, 160, 0, bigInteger4, dHValidationParameters);
}
public DHParameters(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3, int i, int i2, BigInteger bigInteger4, DHValidationParameters dHValidationParameters) {
if (i2 != 0) {
if (i2 > bigInteger.bitLength()) {
throw new IllegalArgumentException("when l value specified, it must satisfy 2^(l-1) <= p");
}
if (i2 < i) {
throw new IllegalArgumentException("when l value specified, it may not be less than m value");
}
}
this.g = bigInteger2;
this.p = bigInteger;
this.q = bigInteger3;
this.m = i;
this.l = i2;
this.j = bigInteger4;
this.validation = dHValidationParameters;
}
public DHParameters(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3, int i, int i2) {
this(bigInteger, bigInteger2, bigInteger3, i, i2, null, null);
}
public DHParameters(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3, int i) {
this(bigInteger, bigInteger2, bigInteger3, getDefaultMParam(i), i, null, null);
}
public DHParameters(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3) {
this(bigInteger, bigInteger2, bigInteger3, 0);
}
public DHParameters(BigInteger bigInteger, BigInteger bigInteger2) {
this(bigInteger, bigInteger2, null, 0);
}
}