使用自定义oids向PKCS#7签名添加经过身份验证/签名的属性?

时间:2012-10-29 18:09:42

标签: cryptography openssl pkcs#7

有没有办法使用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签名{{​​1}},

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 包装openssl功能。

1 个答案:

答案 0 :(得分:5)

不幸的是,无法从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