证明签名的 LTV

LTV of Certifying Signatures

过去几周我一直在使用 iText 在 PDF 文件上进行数字签名,根据我的理解,有两种方法可以将信息添加到 PDF 以使其启用 LTV:

尽管第一种方法生成了一个漂亮整洁的 pdf 文件,但问题是它将 pdf 文件修改为 create/append 导致验证签名无效的条目, 第二个工作正常,但它会根据 crl 列表的大小显着增加 pdf 大小(这也可能会增加加班时间)。

总结一下,除了将信息嵌入签名本身之外,还有其他方法可以启用验证签名 LTV 吗?有什么方法可以在签名时创建 dds/vri 字典吗?

编辑:这里是评论中要求的更多信息:

用于添加lv信息的代码:

    public static void processDocumentLtv(String filePath) throws IOException, GeneralSecurityException, DocumentException {

    long startTime = System.currentTimeMillis();

    File original = new File(filePath);
    File temp = new File(filePath + ".ltv");

    PdfReader reader = new PdfReader(filePath);
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(temp), '[=10=]', true);

    LtvVerification ltvVerification = stamper.getLtvVerification();
    OcspClient ocspClient = new OcspClientBouncyCastle();
    AcroFields fields = stamper.getAcroFields();
    List<String> signatureNames = fields.getSignatureNames();
    String sigName = signatureNames.get(signatureNames.size() - 1);
    PdfPKCS7 pkcs7 = fields.verifySignature(sigName);
    Certificate[] chain = pkcs7.getSignCertificateChain();
    X509Certificate x509certificate = pkcs7.getSigningCertificate();

    byte[] ocspResponse = ocspClient.getEncoded(x509certificate, CertificateUtils.getParent(x509certificate, chain), null);
    Collection<byte[]> crlBytes = CertificateUtils.fetchCrlBytes(x509certificate, chain);
    Collection<byte[]> ocspBytes = null;

    if (ocspResponse != null) {
        ocspBytes = new ArrayList<>();
        ocspBytes.add(ocspResponse);
    }

    ltvVerification.addVerification(sigName, ocspBytes, crlBytes, null);

    ltvVerification.merge();

    stamper.close();
    reader.close();

    Files.copy(temp.toPath(), original.toPath(), StandardCopyOption.REPLACE_EXISTING);
    temp.delete();

    logger.info("Took {}ms to do add the ltv information to the document.", (System.currentTimeMillis() - startTime));
}

文件样本: 在尝试添加 LTV 数据之前:https://www.dropbox.com/s/79ll23ndt9mbh3g/pdf-sample-pre-ltv.pdf?dl=0

通过上面的代码运行后:https://www.dropbox.com/s/hjl73es6hrqspi3/pdf-sample-post-ltv.pdf?dl=0

我正在使用 Adob​​e Reader DC v15.017.20053 作为我的 PDF 查看器。

样本文件的观察结果

我对 OP 的示例 PDF 进行了一些测试。的确,Adobe Acrobat (Reader) 不喜欢 iText 生成的 PAdES-4 LTV 添加到带有 no-changes-allowed 认证的 PDF 中,对此有点脑残,说这两个

Some of the changes that have been made to this document since this signature was applied are not permitted by the document author.

There have been no changes made to this document since this signature was applied.

(按下 计算修改列表 后的 Adob​​e Acrobat 签名属性对话框)

即使我删除了除了添加 LTV 信息之外的任何更改(iText 还调整了文档修改日期元数据),这种情况仍然存在,我最终甚至删除了添加的 Extensions 条目 ESIC (BaseVersion 1.7, ExtensionLevel 5) 向 PDF 查看器指示 PAdES- 4 LTV 内容可能存在,仅保留 DSS 参考和内容。

因此,Adobe Acrobat 违反了 PAdES-4 规范,该规范要求

DocMDP restrictions (see ISO 32000-1 1 clause 12.8.2.2) shall not apply to incremental updates to a PDF document containing a DSS dictionary and associated VRI, Certs, CRLs and OCSPs.

(ETSI TS 102 778-4 V1.1.2 (2009-12) Annex A.1 文档安全存储)

即使 Leonard Rosenthol(当时的 Adob​​e PDF 布道者)在 iText 邮件列表中得到保证

I checked with my engineers and they indeed verified that LTV is fully supported on DocMDP/Cert signatures.

Reply to "Verify certified (with transform method DocMDP) signatures" 2012 年 1 月 17 日;3:15pm)


我没有检查两个选项,不过,如果认证签名是 PAdES-3 签名,或者如果认证文件至少已经在刚刚认证的版本中,Adobe Acrobat 可能只遵守上述 PAdES-4 要求包含一个 Extensions 条目 ESIC (BaseVersion 1.7, ExtensionLevel 5).

手头的文档包含遗留的 ISO 32000-1 签名(可以被视为 PAdES-2 签名,但也可以被视为 PAdES-unaware 签名)并指示 PDF 版本 1.3 没有 ESIC 扩展条目。

在最终将其称为 Adob​​e Acrobat 错误之前,我尝试使用 PAdES-3 签名和 ESIC 扩展条目(或 ADBE 一个根据 PAdES-4 第 4.4 节)。

问题本身

Wrapping up, is there any other way to make the certifying signature LTV enabled other than embedding the information in the signature itself? Is there any way to create the dds/vri dictionaries at signing time?

PAdES-4 添加内容被描述为引用文档先前修订版中的签名,而不是同一修订版中添加的签名。因此,虽然在同一修订版中添加信息在技术上是可能的,但不能保证它们将被符合标准的 PDF 查看器使用。