使用 Pkcs11Interop 和 .NET

问题描述

我目前无法使用 pkcs11interop 和 .NET 将 3DES 密钥导入 HSM。

IObjectAttribute objectAttributes = new List<IObjectAttribute>();
objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_LABEL,"DES3 key"));
objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS,CKO.CKO_SECRET_KEY));
objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_KEY_TYPE,CKK.CKK_DES3));
objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_ENCRYPT,true));
objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_DECRYPT,true));
objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_VALUE,DES3keyvalue));
    
IObjectHandle DES3Key = session.CreateObject(objectAttributes);

参考pkcs11interop官网 https://pkcs11interop.net/doc/_high_level_a_p_i_2_15__create_copy_destroy_object_test_8cs-example.html

我能够想出上面的代码,但会导致 CKR_TEMPLATE_INCONSISTENT 错误

有人知道如何使用 .NET 程序将 3DES 密钥导入 HSM 吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)