是否可以在 PDF 1.4 中使用带有 SHA256 的 ECDSA 签名?

is it possible to use ECDSA signature with SHA256 in PDF 1.4?

我们正在尝试签署生成的 pdf(pdf 版本 1.4),我找不到任何表明 PDF 1.4 支持 ECDSA 的标准。

简而言之

PDF 1.4 中没有关于允许的签名算法的规范要求。此外,PDF 1.4 还不包含对可互操作签名的建议。

PDF 2.0 标准在其 "Signature interoperability" 部分中认为 SHA256withECDSA 只能从 PDF 2.0 开始互操作。

详细

首先,1.7之前的PDF版本没有正确标准化,第一个标准化的通用PDF版本是1.7作为ISO 32000-1:2008。

好的,有 Adob​​e PDF 参考,适用于 1.7 及以下的 PDF 版本;但是 Adobe personal explained 在 iText 邮件列表上 PDF 参考文献本质上不是 "normative" - 他们(通常)不会做出最终的、明确的声明 - 只是一般性的声明。 因此,您无法独立确定给定的陈述对于给定的 PDF 版本是否正确,Adobe 稍后可以判定情况恰恰相反。

尽管如此,PDF 参考 1.4 还是作为 ISO 19005-1:2005 规范 PDF/A-1 的基础,这在一定程度上将此 PDF 参考提升到了半规范级别。因此,让我们假设 PDF 1.4 确实是 "specified" PDF Reference 1.4.

遗憾的是,PDF Reference 1.4 并没有对签名的格式做出太多限制:

The signature may be purely mathematical, such as a public/private-key encrypted document digest, or it may be a biometric form of identification such as a handwritten signature, fingerprint, or retinal scan. The specific form of authentication used is implemented by a plug-in signature handler.

所以在 PDF 1.4 中,由 签名处理程序 来决定什么是允许的,什么不是,这不是 "standard" 的一部分。 =16=]

所示 - 感谢提醒 - PDF Reference 1.4 在上面的引述之后继续说“public-key 数字签名认证的规范是可用于 Adobe 文档 PDF Public-Key Digital Signature and Encryption Specification (见参考书目)。

乍一看,该文档似乎包含要查找的信息。虽然它确实包含比 PDF 参考更多的细节,例如哪些 SubFilter 值对应于 PKCS#1 或 PKCS#7 签名值以及哪些数据(如果有)应嵌入到要签名的 PKCS#7 中,它 描述 PKCS#7 容器中允许使用哪些签名和哈希算法。因此,不幸的是,这份文件对手头的问题没有帮助。

这符合PDF协会的观点,cf.他们的 Technical Note 6:

PDF Reference 1.4 defines how digital signatures are to be embedded into a document. There are aspects of the digital signature that are impacted by the PDF/A-1 standard, e.g. fonts and colors. However, the standard does not make any statements about the semantics, i.e. on how signatures are created and validated. The semantics of digital signatures is left up to the corresponding signature handlers which are uniquely identified by registered names.

因此,技术说明 6 继续从后来的 PDF 参考中派生这些语义

确实,从 PDF 参考 1.5 开始,有部分 "Signature Interoperability" 为可互操作的 PDF 签名提供了越来越具体的指南。

但请注意,这些指南仍然不是一般要求。

根据 PDF 2.0 规范 ISO 32000-2:2017,PDF 版本对可互操作签名的算法限制为:

这认为您的 SHA256withECDSA 签名在 PDF 2.0 之前不可互操作!

除了 MKL 所说的之外,PDF 1.4 中还有更多关于数字签名的信息,但是 'outsourced' 到另一个文件,您可以在 PDF 1.4 规范中阅读:“specification for public-key digital signature authentication is available in the Adob​​e document,PDF Public-Key Digital Signature and Encryption Specification' .“

在介绍中您可以阅读以下内容:

"This specification describes a standard syntax for the storage of data in the signature dictionary and the encryption dictionary of plug-ins that use public-key technology. A degree of interoperability of signed and encrypted PDF files across plug-ins and over time should be possible by using a standardized syntax (see Signature and Encryption Handler Interoperability).

当然,正如 mkl 所写,没有提及特定的 ECDSA 算法等。上述文档不再可用,因为它成为 PDF 1.5 规范的一部分。因此,如果您想确切了解 1.4 中支持的内容,您可以阅读 PDF 1.5 规范或什至 ISO 32000-1 本身以获取该信息。每个功能都用引入它的特定版本“标记”。

在 adobe pdf 规范论坛中有一个类似的 question(通常支持较新的签名类型),您可能会觉得有趣(因为 adobe 规范负责人自己回答):

As far as hashing for digital signatures, there are no technical (file format) restrictions about the use of newer algorithms that still fall into the PDF standard.

HOWEVER, you there is also no expectation that a "conforming reader" will be able to process them, as it need only process those things in PDF 1.4. (Adobe Reader doesn't differentiate in that matter, but someone else might).

简而言之,您可以在 PDF 1.4 中使用更新的签名标准,但您可能不知道 reader 如何处理它。在 adobe reader 的情况下,它会被支持,但对于第 3 方 reader 你不知道。