SoftHSM returns invalid value for `CKA_ALLOWED_MECHANISMS` when there is no limitation

未关闭
#825 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
cpp

调研方向

Start by reading the C_GetAttributeValue handling for CKA_ALLOWED_MECHANISMS and the PKCS#11 v3.2 description linked in the issue. Compare how SoftHSM represents an absent attribute with the zero-length result shown here, and consider the reported application workarounds for context. Done means the returned length follows the chosen PKCS#11 interpretation and the behavior is covered by a regression test.

由索引模型根据 Issue 内容生成。

描述

When listing attributes of object that was created without any allowed algorithms, it should not return empty list (uninitialized pointer + 0 length) as it does now:

76: C_GetAttributeValue
P:2127568; T:0x140248153966528 2025-11-19 17:57:57.573
[in] hSession = 0x1
[in] hObject = 0x2
[in] pTemplate[1]: 
    CKA_ALLOWED_MECHANISMS  0000000000000001 / 0
[out] pTemplate[1]: 
    CKA_ALLOWED_MECHANISMS  0000000000000001 / 0
Returned:  0 CKR_OK

We had to implement a workaround for this in pkcs11-provider before:

https://github.com/latchset/pkcs11-provider/blob/e4f723ddb1a287165177f2d4f5c1635e916526b1/src/sig/rsasig.c#L260-L266

and we are hitting the same issue in rust-cryptoki now parallaxsecond/rust-cryptoki#323 so it would be great to get this fixed.

While this is under-specified in the PKCS#11 standard, returning zero-length is unexpected by most of the application. From my reading of the C_GetAttributeValue description, I think the best would be to set the length to the CK_UNAVAILABLE_INFORMATION to signalize the attribute is valid, but not present on the given object.

https://docs.oasis-open.org/pkcs11/pkcs11-spec/v3.2/pkcs11-spec-v3.2.html#_Toc195693161

主要语言
C++
星标
1.1k
派生
434
平均合并
12 天 14 小时
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

softhsm/SoftHSMv2 的其他 Issue

查看 softhsm/SoftHSMv2 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。