gpt4 book ai didi

cryptography - 将带有自定义 oid 的经过身份验证/签名的属性添加到 PKCS#7 签名?

转载 作者:行者123 更新时间:2023-12-01 22:41:12 24 4
gpt4 key购买 nike

有没有什么方法可以使用 openssl 为 PKCS#7 签名的消息传递额外的经过身份验证的属性?我坚持使用命令行。

我目前正在使用:

openssl smime -sign -outform DER -md sha1 -binary -signer my.crt -inkey my.key

我在 openssl cli 帮助中没有找到任何相关选项。


更多信息:

我目前正在尝试在 NodeJS 中构建一个 SCEP (http://tools.ietf.org/pdf/draft-nourse-scep-23.pdf) 服务器。

SCEP 规范要求构建 PKCS#7 签名的pkiMessages

The SignerInfo MUST contain a set of authenticatedAttributes (see PKCS#7 [RFC2315] Section 9.2 as well as Section 3.1.1 in this document). All messages MUST contain
* an SCEP transactionID attribute
* an SCEP messageType attribute
* an SCEP senderNonce attribute
* any attributes required by PKCS#7 [RFC2315] Section 9.2 If the message is a response, it MUST also include

目前我唯一的选择是通过 child_process.spawn 包装 openssl 功能。

最佳答案

不幸的是,无法从 OpenSSL 命令行(无论是使用 smime 还是 cms 命令)将自定义属性添加到签名消息。如果您想添加一些自定义属性,则必须使用 OpenSSL API。

主要步骤是:

  • 调用CMS_sign创建一个CMS_ContentInfo
  • 使用 CMS_add1_signer 创建 SignerInfo
  • 使用 CMS_signed_add1_attr_by_OBJ 将属性添加到此签名者
  • 使用 CMS_final() 签名

此处有更多详细信息:http://www.openssl.org/docs/crypto/CMS_sign.html

关于cryptography - 将带有自定义 oid 的经过身份验证/签名的属性添加到 PKCS#7 签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13127293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com