com.dyadicsec.provider.EDDSAPrivateKey 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.dyadicsec.provider;
import com.dyadicsec.pkcs11.CKEDDSAPrivateKey;
import com.dyadicsec.pkcs11.CKException;
import com.dyadicsec.pkcs11.CKPrivateKey;
import java.security.KeyStoreException;
import java.security.PrivateKey;
public class EDDSAPrivateKey extends DYKey implements PrivateKey
{
private static final long serialVersionUID = 1L;
KeyParameters keyParams = null;
private EDDSAPublicKey genPublicKey = null;
CKEDDSAPrivateKey pkcs11Key = null;
@Override
protected CKPrivateKey getPkcs11Key() { return pkcs11Key;}
EDDSAPrivateKey()
{
}
EDDSAPrivateKey(CKEDDSAPrivateKey pkcs11Key)
{
this.pkcs11Key = pkcs11Key;
}
EDDSAPrivateKey initForGenerate(KeyParameters keyParams, EDDSAPublicKey genPublicKey)
{
this.keyParams = keyParams;
this.genPublicKey = genPublicKey;
genPublicKey.prvKey = this;
return this;
}
@Override
protected void generate(KeyStore store, String alias) throws KeyStoreException
{
try { pkcs11Key = CKEDDSAPrivateKey.generate(store.slot, alias, KeyParameters.toPolicy(keyParams)); }
catch (CKException e) { throw new KeyStoreException(e); }
if (genPublicKey!=null)
{
try { genPublicKey.pkcs11Key = pkcs11Key.getPublicKey(); }
catch (Throwable e) { throw new KeyStoreException(e); }
}
}
@Override
public String getAlgorithm()
{
return "EDDSA";
}
}