org.spongycastle.pqc.jcajce.provider.mceliece.McElieceCCA2KeysToParams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prov Show documentation
Show all versions of prov Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle
intended for the Android platform. Android unfortunately ships with a stripped-down version of
Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full,
up-to-date version of the Bouncy Castle cryptographic libs.
The newest version!
package org.spongycastle.pqc.jcajce.provider.mceliece;
import java.security.InvalidKeyException;
import java.security.PrivateKey;
import java.security.PublicKey;
import org.spongycastle.crypto.params.AsymmetricKeyParameter;
/**
* utility class for converting jce/jca McElieceCCA2 objects
* objects into their org.spongycastle.crypto counterparts.
*/
public class McElieceCCA2KeysToParams
{
static public AsymmetricKeyParameter generatePublicKeyParameter(
PublicKey key)
throws InvalidKeyException
{
if (key instanceof BCMcElieceCCA2PublicKey)
{
BCMcElieceCCA2PublicKey k = (BCMcElieceCCA2PublicKey)key;
return k.getKeyParams();
}
throw new InvalidKeyException("can't identify McElieceCCA2 public key: " + key.getClass().getName());
}
static public AsymmetricKeyParameter generatePrivateKeyParameter(
PrivateKey key)
throws InvalidKeyException
{
if (key instanceof BCMcElieceCCA2PrivateKey)
{
BCMcElieceCCA2PrivateKey k = (BCMcElieceCCA2PrivateKey)key;
return k.getKeyParams();
}
throw new InvalidKeyException("can't identify McElieceCCA2 private key.");
}
}