All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.unbound.provider.UBEDDSAKeyPairGenerator Maven / Gradle / Ivy

Go to download

This is a collection of JAVA libraries that implement Unbound cryptographic classes for JAVA provider, PKCS11 wrapper, cryptoki, and advapi

There is a newer version: 42761
Show newest version
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); }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy