【问题标题】:Adding PDF revocation information as an signed attribute pdfRevocationInfoArchival OID 1.2.840.113583.1.1.8添加 PDF 撤销信息作为签名属性 pdfRevocationInfoArchival OID 1.2.840.113583.1.1.8
【发布时间】:2020-07-30 08:44:17
【问题描述】:

我们在生成签名时添加了 pdfRevocationInfoArchival OID (1.2.840.113583.1.1.8) 作为签名属性。在构建此属性时,我们使用外部 CRL 文件 (ca-crl.crl) 并将 OID 1.2.840.113583.1.1.8 构建为 ASN1 对象。签署 pdf 和时间戳签名后,一切正常。但是我们无法理解添加在 PDF 中的标识符 (adbe-revocationInfoArchival) 是否正确,并且可以通过获取此 OID 来验证此 PDF。此外,我们无法检查此属性是否采用 PDF 可以验证的正确格式。是否有任何工具或实用程序可用于检查作为签名属性插入的此属性是否有效。

如果任何 PDF 工具/实用程序可用于可视化 PDF 中的属性,请分享。

我们已经在位置 [0] 处构建了颁发者 CRL 信息,在此 OID 中添加 CRL 的方式是否正确?我已经分享了下面的代码sn-p

以下对象标识符标识 Adob​​e 的撤销信息属性:

adbe-revocationInfoArchival OBJECT IDENTIFIER ::=
        { adbe(1.2.840.113583) acrobat(1) security(1) 8 }

Adobe 的 Revocation Information 属性值具有 ASN.1 类型 RevocationInfoArchival:

    /**
     ** RevocationInfoArchival ::= SEQUENCE {
     **   crl [0] EXPLICIT SEQUENCE of CRLs, OPTIONAL
     **   ocsp [1] EXPLICIT SEQUENCE of OCSP Responses, OPTIONAL
     **   otherRevInfo [2] EXPLICIT SEQUENCE of OtherRevInfo, OPTIONAL
      }
    */

在 Java Bouncy Castle API 中使用 Adob​​e 的撤销信息属性值构建:

private ASN1EncodableVector genPdfInfoArchival(ASN1EncodableVector v) {
        
        ASN1EncodableVector v1 = new ASN1EncodableVector();
        
        List<X509CRL> crls = new ArrayList<X509CRL>();
        ASN1InputStream t = null;
        try {
            
            CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
            CRL crl = certFactory.generateCRL(new FileInputStream(new File("e://app//esp//crl//NSDLe-GovCA2019-Test-2.crl")));
            System.out.println("crl:" + crl);
            crls.add((X509CRL)crl);
            
            if (!crls.isEmpty()) {
                ASN1EncodableVector v11 = new ASN1EncodableVector();
                for (Iterator<X509CRL> i = crls.iterator(); i.hasNext();) {
                    t = new ASN1InputStream(new ByteArrayInputStream(i.next().getEncoded()));
                    v11.add(t.readObject());
                }
                //0 for CRL
                v1.add(new DERTaggedObject(true, 0, new DERSequence(v11)));
            }
} 
        
        return v1;}

构建 OID 后,将其作为签名属性添加到 SignerInforGeneratorBuilder 中并生成签名,然后将此签名添加到 PDF 中

            CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
            ASN1EncodableVector signedAttr = new ASN1EncodableVector();
            String ID_ADBE_REVOCATION = "1.2.840.113583.1.1.8";

            //TODO add message digest for sgning - nikhilW
            Attribute attr = new Attribute(CMSAttributes.messageDigest,  new DERSet(new DEROctetString(IOUtils.toByteArray(hashdata))));
            signedAttr.add(attr);
            
            //TODO generate pdf info archival and add it as CMS signed attribute - nikhilW
            ASN1EncodableVector pdfInfo = genPdfInfoArchival(signedAttr);
            Attribute ar = new Attribute(new ASN1ObjectIdentifier(ID_ADBE_REVOCATION),   new DERSet (new DERSequence(pdfInfo)));
            signedAttr.add(ar);
            
            List<Certificate> certList = new ArrayList<Certificate>();
            certList.addAll(Arrays.asList(certificateChain));
            Store certs = new JcaCertStore(certList);
            
            DefaultSignedAttributeTableGenerator sa = new DefaultSignedAttributeTableGenerator(new AttributeTable(signedAttr));
            SignerInfoGeneratorBuilder builder = new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider());
            
            builder.setSignedAttributeGenerator(sa);

请在下面找到包含示例签名 pdf 文件的 google drive 链接 hello_signed_ts_pdfarchivalinfo.pdf
pdf_sample_signed

任何帮助将不胜感激。

【问题讨论】:

    标签: java pdf cryptography signing


    【解决方案1】:

    我已经使用下面的 java 源代码检查了在 pdf 中添加的属性。还有一个 iText Java 实用程序可以调试 pdf 对象树 iText RUP 或从我的谷歌驱动器链接下载它Download iTextRUP Java Jar 使用 java -jar jar-name 运行它可能有助于调试 pdf 对象。

    Pdf 存档信息检索源代码返回位置 [0] 处的 CRL 流对象

    private void getPdfRevoInfoArch(SignerInformation signerInform) {
            
            AttributeTable at = signerInform.getSignedAttributes();
            
            ASN1Encodable arch =    at.get(new ASN1ObjectIdentifier("1.2.840.113583.1.1.8")).getAttrValues().getObjectAt(0);
            
            //ASN1Encodable arch1 = at.get(new ASN1ObjectIdentifier("1.2.840.113583.1.1.8")).getAttrValues().getObjectAt(1);
                    
            System.out.println("arc:" + arch);
            System.out.println("archSize:" + at.get(new ASN1ObjectIdentifier("1.2.840.113583.1.1.8")).getAttrValues().size());
            
        }
    

    【讨论】:

      猜你喜欢
      • 2019-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-24
      • 2013-07-04
      • 1970-01-01
      • 1970-01-01
      • 2019-03-04
      相关资源
      最近更新 更多