aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasamichi Hosoda <trueroad@trueroad.jp>2019-09-27 14:00:30 +0200
committerJay Berkenbilt <ejb@ql.org>2019-10-22 22:16:16 +0200
commit06b818dcd39b5aeaeeee5c247483633a02a0222e (patch)
treed8547c0a002738368913b24685ffdb24b077ee3f
parent5e0ba126871c57a8a688b36614f2b8d78c2675b3 (diff)
downloadqpdf-06b818dcd39b5aeaeeee5c247483633a02a0222e.tar.zst
Exclude signature dictionary from compressible objects
It seems better not to compress signature dictionaries. Various PDF digital signing tools, including Adobe Acrobat Reader DC, do not compress signature dictionaries. Table 8.93 "Entries in a signature dictionary" in PDF 1.5 reference describes that /ByteRange in the signature dictionary shall be used to describe a digest that does not include the signature value (/Contents) itself. The byte ranges cannot be determined if the dictionary is compressed.
-rw-r--r--libqpdf/QPDF.cc8
-rw-r--r--qpdf/qtest/qpdf.test4
2 files changed, 9 insertions, 3 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index c546fbe1..6c0c700a 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -2673,7 +2673,13 @@ QPDF::getCompressibleObjGens()
{
QTC::TC("qpdf", "QPDF exclude encryption dictionary");
}
- else if (! obj.isStream())
+ else if ((! obj.isStream()) &&
+ (! (obj.isDictionary() &&
+ obj.hasKey("/ByteRange") &&
+ obj.hasKey("/Contents") &&
+ obj.hasKey("/Type") &&
+ obj.getKey("/Type").isName() &&
+ obj.getKey("/Type").getName() == "/Sig")))
{
result.push_back(og);
}
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 9fdf9ba2..d5caa9ad 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -3998,9 +3998,9 @@ $td->runtest("fix-qdf with big object stream", # > 255 objects in a stream
show_ntests();
# ----------
$td->notify("--- Signature Dictionary ---");
-$n_tests += 4;
+$n_tests += 6;
-foreach my $i (qw(preserve disable))
+foreach my $i (qw(preserve disable generate))
{
$td->runtest("sig dict contents hex (object-streams=$i)",
{$td->COMMAND =>