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

com.dyadicsec.provider.EDDSAPrivateKey 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.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";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy