iText 分离签名方式

标签 itext digital-signature

能否请您更详细地解释我,最终给我一些示例(一个用于附加,一个用于分离)iText 分离签名的确切含义?

我发现了这个很棒的文档:iText digital signature pdf关于 iText 数字签名,但我仍然不确定我是否理解 iText 分离签名概念。

阅读文档(见链接)我发现了这个定义:

In PDF, we sometimes refer to a detached signature. According to Wikipedia, a detached signature is a type of digital signature that is kept ‘separate from its signed data’, as opposed to ‘bundled together into a single file’. This definition isn’t entirely correct in the context of PDF: the signature is enclosed in the PDF file, but the attributes of the signature are ‘part of the signature’, as opposed to ‘stored in the signature dictionary’.

我不清楚“签名的属性”是什么意思(它指的是什么签名属性?)

请注意,文章的作者(iText 文档)正在使用此签名 PDF 文件的片段:

%PDF-1.4
%âãÏÓ
3 0 obj
<</F 132/Type/Annot/Subtype/Widget/Rect[0 0 0 0]/FT/Sig
/DR<<>>/T(signature)/V 1 0 R/P 4 0 R/AP<</N 2 0 R>>>>
endobj
1 0 obj
<</Contents <0481801e6d931d561563fb254e27c846e08325570847ed63d6f9e35 ... b2c8788a5>
/Type/Sig/SubFilter/adbe.pkcs7.detached/Location(Ghent)/M(D:20120928104114+02'00')
/ByteRange [0 160 16546 1745 ]/Filter/Adobe.PPKLite/Reason(Test)/ContactInfo()>>
endobj
...
9 0 obj
<</Length 63>>stream
q
BT
36 806 Td
0 -18 Td
/F1 12 Tf
(Hello World!)Tj
0 0 Td
ET
Q
endstream
endobj
...
11 0 obj
<</Type/Catalog/AcroForm<</Fields[3 0 R]/DR<</Font<</Helv 5 0 R
/ZaDb 6 0 R>>>>/DA(/Helv 0 Tf 0 g )/SigFlags 3>>/Pages 10 0 R>>
endobj
xref
0 12
0000000000 65535 f
...
0000017736 00000 n
trailer
<</Root 11 0 R/ID [<08ed1afb8ac41e841738c8b24d592465><bd91a30f9c94b8facf5673e7d7c998dc>]/Info 7 0 R/Size 12>>
startxref
17879
%%EOF

最佳答案

虽然您引用的白皮书是 Digital Signatures for PDF documentsBruno Lowagie ,对于任何尝试使用 iText 创建集成 PDF 签名的人来说确实是必读之书(即使您不使用 iText,它也是一个很好的信息来源),我同意其中对在“分离的 PDF 签名”并没有真正打到家:

NOTE: In PDF, we sometimes refer to a detached signature. According to Wikipedia, a detached signature is a type of digital signature that is kept ‘separate from its signed data’, as opposed to ‘bundled together into a single file’. This definition isn’t entirely correct in the context of PDF: the signature is enclosed in the PDF file, but the attributes of the signature are ‘part of the signature’, as opposed to ‘stored in the signature dictionary’.

首先,将这些签名称为“分离”并不是任何当前规范强制执行的术语。无论如何我们这样做的原因是,在此类签名的签名字典中使用的 标识符(adbe.pkcs7.detachedETSI.CAdES.detached) 包含该词。

因此,问题实际上应该是:为什么这些标识符包含“分离”一词?

要理解这一点需要知道,原来有两种集成的PDF签名,将PKCS#7签名容器嵌入到PDF中,分别由adbe.pkcs7.detached标识>adbe.pkcs7.sha1.

这两种签名的区别在于

  • 对于 adbe.pkcs7.sha1 签名,计算 PDF 的带符号字节范围的 SHA1 摘要并嵌入到签名容器的 ContentInfo 结构中 并且这个嵌入的数据包是以 PKCS#7 方式签名的;
  • 另一方面,对于 adbe.pkcs7.detached 签名,签名容器的 ContentInfo 结构为空,并且已签名外部文档的数据范围以 PKCS#7 方式签名。

因此,在 adbe.pkcs7.sha1 签名的情况下,实际签名的数据嵌入到容器中,而在 adbe.pkcs7.detached 签名的情况下,实际签名的数据数据不是。

Thus, on the level of the PKCS#7 signature containers signed data and signature are detached from each other in the latter case.

(事实上,以 PKCS#7 方式签名可以——而且通常确实——包括计算要签名的数据的哈希值,将此哈希值添加到多个 so-称为经过身份验证的属性,并最终签署这些特殊属性,不应分散我们的注意力。)

其他类型的分离签名(ETSI.CAdES.detached)的构造类似于adbe.pkcs7.detached容器。它们之间的区别主要是对容器的附加属性的剖析。

白皮书中关于属性作为签名容器一部分的论证实际上说明了前面提到的所有签名类型与adbe.x509.rsa_sha1签名之间的区别,这是第三种原始集成PDF签名类型。这种类型不是基于签名容器,而是相当裸露的签名;因此,在这种情况下,任何额外信息都必须存储在 PDF 中它们自己的结构中

关于iText 分离签名方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26468316/

相关文章:

java - 将 pdf 附加到 servlet 内存中的 itext pdf

c# - 使用基于 iTextSharp 的模板创建 PDF 文档

c# - 如何使用 C# 从 HTML 转换为 PDF?

pdf - "Not LTV-enabled"是什么意思?

java - 使用远程 Applet 设备进行 XML 签名

digital-signature - Android 应用程序的 "./META-INF/CERT.RSA"文件中包含什么?

java - 我生成了一个 pdf,但保存时更新的是同一个 pdf,而不是新的 pdf

java - Swing 和 iText 字体渲染之间的差异

email - 证书过期时数字签名失败

java - 附件损坏签名第 2 部分