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

26 lines
1.1 KiB
Java

package org.bouncycastle.pqc.jcajce.provider.mceliece;
import java.security.InvalidKeyException;
import java.security.PrivateKey;
import java.security.PublicKey;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
/* loaded from: classes6.dex */
public class McElieceCCA2KeysToParams {
public static AsymmetricKeyParameter generatePublicKeyParameter(PublicKey publicKey) throws InvalidKeyException {
if (publicKey instanceof BCMcElieceCCA2PublicKey) {
return ((BCMcElieceCCA2PublicKey) publicKey).getKeyParams();
}
StringBuilder sb = new StringBuilder("can't identify McElieceCCA2 public key: ");
sb.append(publicKey.getClass().getName());
throw new InvalidKeyException(sb.toString());
}
public static AsymmetricKeyParameter generatePrivateKeyParameter(PrivateKey privateKey) throws InvalidKeyException {
if (privateKey instanceof BCMcElieceCCA2PrivateKey) {
return ((BCMcElieceCCA2PrivateKey) privateKey).getKeyParams();
}
throw new InvalidKeyException("can't identify McElieceCCA2 private key.");
}
}