28 lines
1.4 KiB
Java
28 lines
1.4 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;
|
|
import org.bouncycastle.pqc.crypto.mceliece.McEliecePrivateKeyParameters;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class McElieceKeysToParams {
|
|
public static AsymmetricKeyParameter generatePublicKeyParameter(PublicKey publicKey) throws InvalidKeyException {
|
|
if (publicKey instanceof BCMcEliecePublicKey) {
|
|
return ((BCMcEliecePublicKey) publicKey).getKeyParams();
|
|
}
|
|
StringBuilder sb = new StringBuilder("can't identify McEliece public key: ");
|
|
sb.append(publicKey.getClass().getName());
|
|
throw new InvalidKeyException(sb.toString());
|
|
}
|
|
|
|
public static AsymmetricKeyParameter generatePrivateKeyParameter(PrivateKey privateKey) throws InvalidKeyException {
|
|
if (!(privateKey instanceof BCMcEliecePrivateKey)) {
|
|
throw new InvalidKeyException("can't identify McEliece private key.");
|
|
}
|
|
BCMcEliecePrivateKey bCMcEliecePrivateKey = (BCMcEliecePrivateKey) privateKey;
|
|
return new McEliecePrivateKeyParameters(bCMcEliecePrivateKey.getN(), bCMcEliecePrivateKey.getK(), bCMcEliecePrivateKey.getField(), bCMcEliecePrivateKey.getGoppaPoly(), bCMcEliecePrivateKey.getP1(), bCMcEliecePrivateKey.getP2(), bCMcEliecePrivateKey.getSInv());
|
|
}
|
|
}
|