PKCS#11 Generate AES key

我是研究僧i 提交于 2019-12-05 07:38:36

I found the answere, new CK_ATTRIBUTE(CKA.VALUE_LEN, 32), , the 32 in there has to be CK_ULONG value so when i do this:

LongRef l = new LongRef((long)32);

CK_ATTRIBUTE[] template =
{
    new CK_ATTRIBUTE(CKA.CLASS,     CKO.SECRET_KEY),
    new CK_ATTRIBUTE(CKA.TOKEN,     CK_BBOOL.TRUE),
    new CK_ATTRIBUTE(CKA.SENSITIVE, CK_BBOOL.TRUE),
    new CK_ATTRIBUTE(CKA.VALUE_LEN, l.value),
    //new CK_ATTRIBUTE(CKA.VALUE,     key),
    new CK_ATTRIBUTE(CKA.KEY_TYPE,  CKK.AES),
    new CK_ATTRIBUTE(CKA.LABEL,     "testAES".getBytes()),
    new CK_ATTRIBUTE(CKA.PRIVATE,   new CK_BBOOL(bPrivate))
};

Where LongRef is:

public class LongRef {

    public long value; 

    public LongRef(long l) {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }
}

Hope this helps someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!