what-the-bank/sources/org/bouncycastle/pqc/jcajce/spec/McElieceKeyGenParameterSpec...

100 lines
2.8 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.pqc.jcajce.spec;
import java.security.InvalidParameterException;
import java.security.spec.AlgorithmParameterSpec;
import org.bouncycastle.pqc.math.linearalgebra.PolynomialRingGF2;
/* loaded from: classes6.dex */
public class McElieceKeyGenParameterSpec implements AlgorithmParameterSpec {
public static final int DEFAULT_M = 11;
public static final int DEFAULT_T = 50;
private int fieldPoly;
private int m;
private int n;
private int t;
public int getT() {
return this.t;
}
public int getN() {
return this.n;
}
public int getM() {
return this.m;
}
public int getFieldPoly() {
return this.fieldPoly;
}
public McElieceKeyGenParameterSpec(int i, int i2, int i3) {
this.m = i;
if (i <= 0) {
throw new IllegalArgumentException("m must be positive");
}
if (i > 32) {
throw new IllegalArgumentException(" m is too large");
}
int i4 = 1 << i;
this.n = i4;
this.t = i2;
if (i2 < 0) {
throw new IllegalArgumentException("t must be positive");
}
if (i2 > i4) {
throw new IllegalArgumentException("t must be less than n = 2^m");
}
if (PolynomialRingGF2.degree(i3) != i || !PolynomialRingGF2.isIrreducible(i3)) {
throw new IllegalArgumentException("polynomial is not a field polynomial for GF(2^m)");
}
this.fieldPoly = i3;
}
public McElieceKeyGenParameterSpec(int i, int i2) throws InvalidParameterException {
if (i <= 0) {
throw new IllegalArgumentException("m must be positive");
}
if (i > 32) {
throw new IllegalArgumentException("m is too large");
}
this.m = i;
int i3 = 1 << i;
this.n = i3;
if (i2 < 0) {
throw new IllegalArgumentException("t must be positive");
}
if (i2 > i3) {
throw new IllegalArgumentException("t must be less than n = 2^m");
}
this.t = i2;
this.fieldPoly = PolynomialRingGF2.getIrreduciblePolynomial(i);
}
public McElieceKeyGenParameterSpec(int i) {
if (i <= 0) {
throw new IllegalArgumentException("key size must be positive");
}
this.m = 0;
this.n = 1;
while (true) {
int i2 = this.n;
if (i2 >= i) {
int i3 = i2 >>> 1;
this.t = i3;
int i4 = this.m;
this.t = i3 / i4;
this.fieldPoly = PolynomialRingGF2.getIrreduciblePolynomial(i4);
return;
}
this.n = i2 << 1;
this.m++;
}
}
public McElieceKeyGenParameterSpec() {
this(11, 50);
}
}