如何在 Java 应用程序中使用 Microsoft PKCS#9 SignerInfo 属性?

发布于 2024-08-21 04:28:03 字数 663 浏览 3 评论 0原文

http://msdn. microsoft.com/en-us/library/system.security.cryptography.pkcs(VS.85).aspx 我们可以看到定义了以下数字签名属性:

  • Pkcs9ContentType
  • Pkcs9DocumentDescription
  • Pkcs9DocumentName
  • Pkcs9MessageDigest
  • Pkcs9SigningTime

其中,Pkcs9DocumentDescriptionPkcs9DocumentName 不存在于 中PKCS#9 规范。我有一个使用 Bouncy Castle 的 Java 应用程序,我希望我的应用程序能够创建具有这两个属性的数字签名。

所以,我有两个问题:如何做到这一点?我应该这样做吗?

In http://msdn.microsoft.com/en-us/library/system.security.cryptography.pkcs(VS.85).aspx we can see that the following digital signature attributes are defined:

  • Pkcs9ContentType
  • Pkcs9DocumentDescription
  • Pkcs9DocumentName
  • Pkcs9MessageDigest
  • Pkcs9SigningTime

Of those, Pkcs9DocumentDescription and Pkcs9DocumentName are not present in the PKCS#9 specification. I have a Java application that uses Bouncy Castle and I want my app to be able to create digital signatures that have these two attributes.

So, I have two questions: how to do so? Should I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖阳 2024-08-28 04:28:03

您必须使用 OID 手动构建属性,如下所示:

ObjectIdentifier dnOid = new ObjectIdentifier("1.3.6.1.4.1.311.88.2.1");
ObjectIdentifier ddOid = new ObjectIdentifier("1.3.6.1.4.1.311.88.2.2");
ASN1Set nameSet = new DERSet(new ASN1Encodable[] {new DERPrintableString("name")});
ASN1Set descriptionSet = new DERSet(new ASN1Encodable[] {new DERPrintableString("description"}));
Attribute documentName = new Attribute(dnOid, nameSet);
Attribute documentDescription = new Attribute(ddOid, descriptionSet);

我应该指出,使用 DERPrintableString 作为属性值是我的最佳猜测。我找不到指示正确类型的文档。

至于你应该吗?好吧,使用不是来自 PKCS #9 的属性并没有什么问题。您只是不应该依赖能够使用它们的外部系统。

You'll have to manually build the attributes using the OIDs, like so:

ObjectIdentifier dnOid = new ObjectIdentifier("1.3.6.1.4.1.311.88.2.1");
ObjectIdentifier ddOid = new ObjectIdentifier("1.3.6.1.4.1.311.88.2.2");
ASN1Set nameSet = new DERSet(new ASN1Encodable[] {new DERPrintableString("name")});
ASN1Set descriptionSet = new DERSet(new ASN1Encodable[] {new DERPrintableString("description"}));
Attribute documentName = new Attribute(dnOid, nameSet);
Attribute documentDescription = new Attribute(ddOid, descriptionSet);

I should point out that using DERPrintableString for the attribute value is my best guess. I can't find the documentation for indicating the correct type.

As for should you, well, there's nothing wrong with using Attributes which aren't from PKCS #9. You just shouldn't rely on an external system being able to use them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文