简体   繁体   English

SoftHSMv2 - 如何使创建的对象在会话之间存活?

[英]SoftHSMv2 - How to make created objects survive between sessions?

  1. I open a session我开了一个session
  2. I create an AES key with a label by using C_CreateObject我使用 C_CreateObject 创建一个带有 label 的 AES 密钥
  3. I can lookup the created object by label by using C_FindObjects.我可以使用 C_FindObjects 查找由 label 创建的 object。
  4. I close the session.我关闭 session。
  5. I open a new session.我新开了一个session。
  6. I can no longer lookup the created object by label using C_FindObjects.我无法再使用 C_FindObjects 查找 label 创建的 object。

What am I doing wrong?我究竟做错了什么?

Thanks!谢谢!

Two possibilities come to my mind:我想到了两种可能性:

  1. Per PKCS#11 2.40 ,根据PKCS#11 2.40

Only session objects can be created during a read-only session在只读期间只能创建 session 个对象 session

Therefore the session of C_CreateObject needs to have been opened with the flags argument set to CKF_SERIAL_SESSION | CKF_RW_SESSION因此,需要打开 C_CreateObject 的C_CreateObject ,并将flags参数设置为CKF_SERIAL_SESSION | CKF_RW_SESSION CKF_SERIAL_SESSION | CKF_RW_SESSION . CKF_SERIAL_SESSION | CKF_RW_SESSION

  1. The pTemplate argment to C_CreateObject needs to include the CKA_TOKEN attribute so that the newly created key would be a "token object" rather than a "session object". pTemplateC_CreateObject需要包含CKA_TOKEN属性,以便新创建的密钥将是“令牌对象”而不是“会话对象”。

In PKCS#11, a token object is persistent across sessions whereas a session object is ephemeral and would get dropped once the session is closed.在 PKCS#11 中,令牌 object 在会话中持久存在,而 session object 是短暂的,一旦 session 关闭就会被丢弃。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM