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

93 lines
3.2 KiB
Java

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.CipherParameters;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.pqc.asn1.McElieceCCA2PublicKey;
import org.bouncycastle.pqc.asn1.PQCObjectIdentifiers;
import org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2PublicKeyParameters;
import org.bouncycastle.pqc.math.linearalgebra.GF2Matrix;
/* loaded from: classes6.dex */
public class BCMcElieceCCA2PublicKey implements CipherParameters, PublicKey {
private static final long serialVersionUID = 1;
private McElieceCCA2PublicKeyParameters 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().toString());
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.mcElieceCca2), new McElieceCCA2PublicKey(this.params.getN(), this.params.getT(), this.params.getG(), Utils.getDigAlgId(this.params.getDigest()))).getEncoded();
} catch (IOException unused) {
return null;
}
}
@Override // java.security.Key
public String getAlgorithm() {
return "McEliece-CCA2";
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof BCMcElieceCCA2PublicKey)) {
return false;
}
BCMcElieceCCA2PublicKey bCMcElieceCCA2PublicKey = (BCMcElieceCCA2PublicKey) obj;
return this.params.getN() == bCMcElieceCCA2PublicKey.getN() && this.params.getT() == bCMcElieceCCA2PublicKey.getT() && this.params.getG().equals(bCMcElieceCCA2PublicKey.getG());
}
public BCMcElieceCCA2PublicKey(McElieceCCA2PublicKeyParameters mcElieceCCA2PublicKeyParameters) {
this.params = mcElieceCCA2PublicKeyParameters;
}
}