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

119 lines
3.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.pqc.jcajce.spec;
import java.security.spec.AlgorithmParameterSpec;
import org.bouncycastle.pqc.math.linearalgebra.PolynomialRingGF2;
/* loaded from: classes6.dex */
public class McElieceCCA2KeyGenParameterSpec implements AlgorithmParameterSpec {
public static final int DEFAULT_M = 11;
public static final int DEFAULT_T = 50;
public static final String SHA1 = "SHA-1";
public static final String SHA224 = "SHA-224";
public static final String SHA256 = "SHA-256";
public static final String SHA384 = "SHA-384";
public static final String SHA512 = "SHA-512";
private final String digest;
private int fieldPoly;
private final int m;
private final int n;
private final 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 String getDigest() {
return this.digest;
}
public McElieceCCA2KeyGenParameterSpec(int i, String str) {
if (i <= 0) {
throw new IllegalArgumentException("key size must be positive");
}
int i2 = 1;
int i3 = 0;
while (i2 < i) {
i2 <<= 1;
i3++;
}
this.t = (i2 >>> 1) / i3;
this.m = i3;
this.n = i2;
this.fieldPoly = PolynomialRingGF2.getIrreduciblePolynomial(i3);
this.digest = str;
}
public McElieceCCA2KeyGenParameterSpec(int i, int i2, String str) {
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);
this.digest = str;
}
public McElieceCCA2KeyGenParameterSpec(int i, int i2, int i3, String str) {
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;
this.digest = str;
}
public McElieceCCA2KeyGenParameterSpec(int i, int i2, int i3) {
this(i, i2, i3, SHA256);
}
public McElieceCCA2KeyGenParameterSpec(int i, int i2) {
this(i, i2, SHA256);
}
public McElieceCCA2KeyGenParameterSpec(int i) {
this(i, SHA256);
}
public McElieceCCA2KeyGenParameterSpec() {
this(11, 50, SHA256);
}
}