org.bouncycastle.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 bcprov-ext-jdk15on Show documentation
Show all versions of bcprov-ext-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.7. Note: this package includes the IDEA and NTRU encryption algorithms.
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.McElieceCCA2PrivateKeyParameters;
import org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2PublicKeyParameters;
/**
* utility class for converting jce/jca McElieceCCA2 objects
* objects into their org.bouncycastle.crypto counterparts.
*/
public class McElieceCCA2KeysToParams
{
static public AsymmetricKeyParameter generatePublicKeyParameter(
PublicKey key)
throws InvalidKeyException
{
if (key instanceof BCMcElieceCCA2PublicKey)
{
BCMcElieceCCA2PublicKey k = (BCMcElieceCCA2PublicKey)key;
return new McElieceCCA2PublicKeyParameters(k.getOIDString(), k.getN(), k.getT(), k.getG(), k.getMcElieceCCA2Parameters());
}
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 new McElieceCCA2PrivateKeyParameters(k.getOIDString(), k.getN(), k.getK(), k.getField(), k.getGoppaPoly(),
k.getP(), k.getH(), k.getQInv(), k.getMcElieceCCA2Parameters());
}
throw new InvalidKeyException("can't identify McElieceCCA2 private key.");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy