what-the-bank/sources/org/bouncycastle/pqc/jcajce/provider/newhope/BCNHPublicKey.java

65 lines
2.0 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.pqc.jcajce.provider.newhope;
import java.io.IOException;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.pqc.asn1.PQCObjectIdentifiers;
import org.bouncycastle.pqc.crypto.newhope.NHPublicKeyParameters;
import org.bouncycastle.pqc.jcajce.interfaces.NHPublicKey;
import org.bouncycastle.util.Arrays;
/* loaded from: classes6.dex */
public class BCNHPublicKey implements NHPublicKey {
private static final long serialVersionUID = 1;
private final NHPublicKeyParameters params;
public int hashCode() {
return Arrays.hashCode(this.params.getPubData());
}
@Override // org.bouncycastle.pqc.jcajce.interfaces.NHPublicKey
public byte[] getPublicData() {
return this.params.getPubData();
}
/* JADX INFO: Access modifiers changed from: package-private */
public CipherParameters getKeyParams() {
return this.params;
}
@Override // java.security.Key
public String getFormat() {
return "X.509";
}
@Override // java.security.Key
public byte[] getEncoded() {
try {
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(PQCObjectIdentifiers.newHope), this.params.getPubData()).getEncoded();
} catch (IOException unused) {
return null;
}
}
@Override // java.security.Key
public final String getAlgorithm() {
return "NH";
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof BCNHPublicKey)) {
return false;
}
return Arrays.areEqual(this.params.getPubData(), ((BCNHPublicKey) obj).params.getPubData());
}
public BCNHPublicKey(NHPublicKeyParameters nHPublicKeyParameters) {
this.params = nHPublicKeyParameters;
}
public BCNHPublicKey(SubjectPublicKeyInfo subjectPublicKeyInfo) {
this.params = new NHPublicKeyParameters(subjectPublicKeyInfo.getPublicKeyData().getBytes());
}
}