what-the-bank/sources/org/bouncycastle/pqc/jcajce/provider/mceliece/BCMcEliecePublicKey.java

92 lines
3.0 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.pqc.jcajce.provider.mceliece;
import java.io.IOException;
import java.security.PublicKey;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.pqc.asn1.McEliecePublicKey;
import org.bouncycastle.pqc.asn1.PQCObjectIdentifiers;
import org.bouncycastle.pqc.crypto.mceliece.McEliecePublicKeyParameters;
import org.bouncycastle.pqc.math.linearalgebra.GF2Matrix;
/* loaded from: classes6.dex */
public class BCMcEliecePublicKey implements PublicKey {
private static final long serialVersionUID = 1;
private McEliecePublicKeyParameters params;
public String toString() {
StringBuilder sb = new StringBuilder("McEliecePublicKey:\n length of the code : ");
sb.append(this.params.getN());
sb.append("\n");
String obj = sb.toString();
StringBuilder sb2 = new StringBuilder();
sb2.append(obj);
sb2.append(" error correction capability: ");
sb2.append(this.params.getT());
sb2.append("\n");
String obj2 = sb2.toString();
StringBuilder sb3 = new StringBuilder();
sb3.append(obj2);
sb3.append(" generator matrix : ");
sb3.append(this.params.getG());
return sb3.toString();
}
public int hashCode() {
return ((this.params.getN() + (this.params.getT() * 37)) * 37) + this.params.getG().hashCode();
}
public int getT() {
return this.params.getT();
}
public int getN() {
return this.params.getN();
}
/* JADX INFO: Access modifiers changed from: package-private */
public AsymmetricKeyParameter getKeyParams() {
return this.params;
}
public int getK() {
return this.params.getK();
}
public GF2Matrix getG() {
return this.params.getG();
}
@Override // java.security.Key
public String getFormat() {
return "X.509";
}
@Override // java.security.Key
public byte[] getEncoded() {
try {
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(PQCObjectIdentifiers.mcEliece), new McEliecePublicKey(this.params.getN(), this.params.getT(), this.params.getG())).getEncoded();
} catch (IOException unused) {
return null;
}
}
@Override // java.security.Key
public String getAlgorithm() {
return "McEliece";
}
public boolean equals(Object obj) {
if (!(obj instanceof BCMcEliecePublicKey)) {
return false;
}
BCMcEliecePublicKey bCMcEliecePublicKey = (BCMcEliecePublicKey) obj;
return this.params.getN() == bCMcEliecePublicKey.getN() && this.params.getT() == bCMcEliecePublicKey.getT() && this.params.getG().equals(bCMcEliecePublicKey.getG());
}
public BCMcEliecePublicKey(McEliecePublicKeyParameters mcEliecePublicKeyParameters) {
this.params = mcEliecePublicKeyParameters;
}
}