代码之家  ›  专栏  ›  技术社区  ›  Thiago Chaves

如何在Java应用程序中使用微软PKCS的9签名信息属性?

  •  1
  • Thiago Chaves  · 技术社区  · 16 年前

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

    • PKCS9内容类型
    • PKCS9文档说明
    • PKCS9documentname文件名
    • PKCS9MessageDigest文件
    • PKCS9签约时间

    其中, PKCS9文档说明 PKCS9documentname文件名 不存在于 PKCS#9 specification . 我有一个Java应用程序 弹跳城堡 我希望我的应用程序能够创建具有这两个属性的数字签名。

    所以,我有两个问题:怎么做?我应该那样做吗?

    1 回复  |  直到 16 年前
        1
  •  0
  •   David Grant    16 年前

    您必须使用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 . 你不应该依赖外部系统来使用它们。