【发布时间】:2018-10-16 09:19:47
【问题描述】:
我已经效仿了:https://pkcs11interop.net/doc/_high_level_a_p_i_2_24__wrap_and_unwrap_key_test_8cs-example.html
使用 rsa 密钥来包装对称密钥,并且成功了。
我想要实现的是包装一个非对称密钥(rsa 私钥)。我所做的只是用私钥的 ObjectHandle 替换“secretKey”变量。但是,每次调用 Wrapkey 函数时都会收到 CKR_GENERAL_ERROR。
有人可以解释为什么这不起作用吗?我在规范中找不到任何阻止包装非对称密钥的内容。
生成的私钥具有以下属性:
List<ObjectAttribute> privateKeyAttributes = new List<ObjectAttribute>();
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_TOKEN, true));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_PRIVATE, true));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_ID, ConvertUtils.HexStringToBytes(id)));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_SENSITIVE, false));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_DECRYPT, true));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_SIGN, true));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_SIGN_RECOVER, true));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_EXTRACTABLE, true));
最好的问候,
【问题讨论】: