简体   繁体   English

如何在安全令牌中保存临时值?

[英]How to save a temporary value in a security token?

Is it possible to save a value in a security token memory by using PyKCS11 and M2Crypto? 是否可以通过使用PyKCS11和M2Crypto将值保存在安全令牌存储器中?

I need to save an integer to token memory, so that the value can be carried out with the token 我需要将一个整数保存到令牌内存中,以便可以使用令牌来执行该值

I know how to create objects, but is it possible to create attributes in a token, so whenever I read that attribute I will know the status of that token. 我知道如何创建对象,但是可以在令牌中创建属性,因此,每当我读取该属性时,我都会知道该令牌的状态。

using PKCS#11, the only way to store 'home made' data, it through the use of a CKO_DATA object type. 使用PKCS#11是存储“自制”数据的唯一方法,它是通过使用CKO_DATA对象类型来实现的。 Like any object, it can be persistent on the token (not lost when the token is powered off) or it can be a memory object (lost when the session to the token is closed). 像任何对象一样,它可以在令牌上持久化(在令牌关闭电源时不会丢失),也可以是内存对象(在与令牌的会话关闭时丢失)。

To create a CKO_DATA object is similar to any other object creation: 创建CKO_DATA对象类似于创建任何其他对象:

  • open a r/w session on the slot 在插槽上打开一个读写会话
  • if the object is to be protected by user authentication ( CKU_USER ) then Login as user 如果对象要通过用户身份验证( CKU_USER )保护, 则以用户身份登录
  • create the object template with mandatory attributes such as CKA_CLASS etc. ( refer to the PKCS#11 specifications for details ) 使用强制属性(例如CKA_CLASS等)创建对象模板( 有关详细信息,请参阅PKCS#11规范
  • set the CKA_TOKEN to TRUE if the object is to be persistent, or FALSE if it is a memory object 如果该对象是持久性对象, 则将CKA_TOKEN设置为TRUE;如果它是一个内存对象,则将其设置为FALSE
  • set the CKA_PRIVATE to TRUE* if you want this object to be read/writen only upon successfull user authentication or set it to **FALSE if anybody can access it. 如果您希望仅在成功的用户身份验证后才可读写此对象,请将CKA_PRIVATE设置为TRUE *;如果有人可以访问,则将其设置为** FALSE
  • set a CKA_LABEL and CKA_APPLICATION attributes with values you want to help you find the object next time 使用您想帮助下次找到对象的值设置CKA_LABELCKA_APPLICATION属性
  • set the CKA_VALUE attribute to the value you want (your integer) CKA_VALUE属性设置为所需的值(您的整数)
  • Call C_CreateObject , using this template will create the desired object. 调用C_CreateObject ,使用该模板将创建所需的对象。

HTH, HTH,

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

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