55 lines
1.9 KiB
Java
55 lines
1.9 KiB
Java
|
package org.bouncycastle.crypto.agreement.jpake;
|
||
|
|
||
|
import com.pingan.ai.p;
|
||
|
import java.math.BigInteger;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class JPAKEPrimeOrderGroup {
|
||
|
private final BigInteger g;
|
||
|
private final BigInteger p;
|
||
|
private final BigInteger q;
|
||
|
|
||
|
public BigInteger getQ() {
|
||
|
return this.q;
|
||
|
}
|
||
|
|
||
|
public BigInteger getP() {
|
||
|
return this.p;
|
||
|
}
|
||
|
|
||
|
public BigInteger getG() {
|
||
|
return this.g;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public JPAKEPrimeOrderGroup(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3, boolean z) {
|
||
|
JPAKEUtil.validateNotNull(bigInteger, p.a);
|
||
|
JPAKEUtil.validateNotNull(bigInteger2, "q");
|
||
|
JPAKEUtil.validateNotNull(bigInteger3, "g");
|
||
|
if (!z) {
|
||
|
if (!bigInteger.subtract(JPAKEUtil.ONE).mod(bigInteger2).equals(JPAKEUtil.ZERO)) {
|
||
|
throw new IllegalArgumentException("p-1 must be evenly divisible by q");
|
||
|
}
|
||
|
if (bigInteger3.compareTo(BigInteger.valueOf(2L)) == -1 || bigInteger3.compareTo(bigInteger.subtract(JPAKEUtil.ONE)) == 1) {
|
||
|
throw new IllegalArgumentException("g must be in [2, p-1]");
|
||
|
}
|
||
|
if (!bigInteger3.modPow(bigInteger2, bigInteger).equals(JPAKEUtil.ONE)) {
|
||
|
throw new IllegalArgumentException("g^q mod p must equal 1");
|
||
|
}
|
||
|
if (!bigInteger.isProbablePrime(20)) {
|
||
|
throw new IllegalArgumentException("p must be prime");
|
||
|
}
|
||
|
if (!bigInteger2.isProbablePrime(20)) {
|
||
|
throw new IllegalArgumentException("q must be prime");
|
||
|
}
|
||
|
}
|
||
|
this.p = bigInteger;
|
||
|
this.q = bigInteger2;
|
||
|
this.g = bigInteger3;
|
||
|
}
|
||
|
|
||
|
public JPAKEPrimeOrderGroup(BigInteger bigInteger, BigInteger bigInteger2, BigInteger bigInteger3) {
|
||
|
this(bigInteger, bigInteger2, bigInteger3, false);
|
||
|
}
|
||
|
}
|