org.bouncycastle.pqc.crypto.frodo.FrodoKeyPairGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk14 Show documentation
Show all versions of bcprov-jdk14 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.4.
package org.bouncycastle.pqc.crypto.frodo;
import java.security.SecureRandom;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator;
import org.bouncycastle.crypto.KeyGenerationParameters;
public class FrodoKeyPairGenerator
implements AsymmetricCipherKeyPairGenerator
{
private FrodoKeyGenerationParameters frodoParams;
private int n;
private int D;
private int B;
private SecureRandom random;
private void initialize(
KeyGenerationParameters param)
{
this.frodoParams = (FrodoKeyGenerationParameters)param;
this.random = param.getRandom();
this.n = this.frodoParams.getParameters().getN();
this.D = this.frodoParams.getParameters().getD();
this.B = this.frodoParams.getParameters().getB();
}
private AsymmetricCipherKeyPair genKeyPair()
{
FrodoEngine engine = frodoParams.getParameters().getEngine();
byte[] sk = new byte[engine.getPrivateKeySize()];
byte[] pk = new byte[engine.getPublicKeySize()];
engine.kem_keypair(pk, sk, random);
FrodoPublicKeyParameters pubKey = new FrodoPublicKeyParameters(frodoParams.getParameters(), pk);
FrodoPrivateKeyParameters privKey = new FrodoPrivateKeyParameters(frodoParams.getParameters(), sk);
return new AsymmetricCipherKeyPair(pubKey, privKey);
}
public void init(KeyGenerationParameters param)
{
this.initialize(param);
}
public AsymmetricCipherKeyPair generateKeyPair()
{
return genKeyPair();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy