![JAR search and dependency download from the Maven repository](/logo.png)
com.unbound.client.pkcs11.PKCS11ECPRFKey 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.client.pkcs11;
import com.dyadicsec.cryptoki.*;
import com.unbound.client.ECPRFKey;
import com.unbound.client.ObjectType;
import com.unbound.provider.KeyParameters;
import java.security.ProviderException;
import java.util.ArrayList;
import static com.dyadicsec.cryptoki.CK.*;
import static com.dyadicsec.cryptoki.CK.CKA_WRAP_WITH_TRUSTED;
public class PKCS11ECPRFKey extends PKCS11Object implements ECPRFKey
{
PKCS11ECPRFKey(PKCS11Session session, int handle)
{
super(ObjectType.ECPrf, handle);
read(session);
}
static ArrayList getNewTemplate(String name, KeyParameters kp)
{
if (name==null && kp!=null) name = kp.getName();
ArrayList t = new ArrayList();
try
{
t.add(new CK_ATTRIBUTE(CKA_TOKEN, kp==null || kp.isToken()));
t.add(new CK_ATTRIBUTE(CKA_CLASS, CKO_PRIVATE_KEY));
t.add(new CK_ATTRIBUTE(CKA_KEY_TYPE, DYCKK_ADV_PRF));
if (name!=null) t.add(new CK_ATTRIBUTE(CKA_ID, strToId(name)));
if (kp!=null)
{
if (kp.isSetEncrypt()) t.add(new CK_ATTRIBUTE(CKA_ENCRYPT, kp.isAllowEncrypt()));
if (kp.isSetDecrypt()) t.add(new CK_ATTRIBUTE(CKA_DECRYPT, kp.isAllowDecrypt()));
if (kp.isSetDerive()) t.add(new CK_ATTRIBUTE(CKA_DERIVE, kp.isAllowDerive()));
makeExportLevel(t, kp);
}
}
catch (CKR_Exception e)
{
throw new ProviderException(e);
}
return t;
}
static PKCS11ECPRFKey generate(PKCS11Session session, String name, KeyParameters kp)
{
try
{
ArrayList t = getNewTemplate(name, kp);
int handle = Library.C_GenerateKey(session.getHandle(), new CK_MECHANISM(DYCKM_PRF_KEY_GEN), getAttrs(t));
return new PKCS11ECPRFKey(session, handle);
}
catch (CKR_Exception e) { throw new ProviderException(e); }
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy