com.unbound.provider.UBEDDSAKeyPairGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unbound-java-provider Show documentation
Show all versions of unbound-java-provider Show documentation
This is a collection of JAVA libraries that implement Unbound cryptographic classes for JAVA provider, PKCS11 wrapper, cryptoki, and advapi
package com.unbound.provider;
import com.unbound.client.EDDSAPrivateKeyObject;
import com.unbound.client.Partition;
import java.security.*;
import java.security.spec.AlgorithmParameterSpec;
public class UBEDDSAKeyPairGenerator extends KeyPairGeneratorSpi
{
private final Partition partition;
private KeyParameters keyParameter = null;
public UBEDDSAKeyPairGenerator(Partition partition)
{
this.partition = partition;
}
@Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException
{
if (!(params instanceof KeyGenSpec)) throw new InvalidAlgorithmParameterException("Not supported algorithm parameter spec");
keyParameter = ((KeyGenSpec)params).getKeyParams();
initialize(((KeyGenSpec)params).getBitSize(), random);
}
@Override
public void initialize(int keysize, SecureRandom random)
{
}
@Override
public KeyPair generateKeyPair()
{
try
{
EDDSAPrivateKeyObject object = partition.generateEddsaKey(null, keyParameter);
byte[] pubKeyValue = object.getPublicKeyValue();
return new KeyPair(new UBEDDSAPublicKey(partition, pubKeyValue), new UBEDDSAPrivateKey(object));
}
catch (Exception e) { throw new ProviderException(e); }
}
}