diff options
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qtest/qpdf.test | 13 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/encrypt-before-filename.out | 20 | ||||
-rw-r--r-- | qpdf/test_driver.cc | 13 |
3 files changed, 46 insertions, 0 deletions
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index e1db8b89..0274f604 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -3522,6 +3522,19 @@ foreach my $d (@enc_key) $td->NORMALIZE_NEWLINES); } +# Miscellaneous encryption tests +$n_tests += 2; + +$td->runtest("set encryption before set filename", + {$td->COMMAND => "test_driver 63 minimal.pdf"}, + {$td->STRING => "test 63 done\n", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("check file's validity", + {$td->COMMAND => "qpdf --check --password=u a.pdf"}, + {$td->FILE => "encrypt-before-filename.out", + $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); + show_ntests(); # ---------- $td->notify("--- Unicode Passwords ---"); diff --git a/qpdf/qtest/qpdf/encrypt-before-filename.out b/qpdf/qtest/qpdf/encrypt-before-filename.out new file mode 100644 index 00000000..e7d7dbd4 --- /dev/null +++ b/qpdf/qtest/qpdf/encrypt-before-filename.out @@ -0,0 +1,20 @@ +checking a.pdf +PDF Version: 1.7 extension level 8 +R = 6 +P = -4 +User password = u +extract for accessibility: allowed +extract for any purpose: allowed +print low resolution: allowed +print high resolution: allowed +modify document assembly: allowed +modify forms: allowed +modify annotations: allowed +modify other: allowed +modify anything: allowed +stream encryption method: AESv3 +string encryption method: AESv3 +file encryption method: AESv3 +File is not linearized +No syntax or stream encoding errors found; the file may still contain +errors that qpdf cannot detect diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 7fb84a8f..7aed39ba 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -2094,6 +2094,19 @@ void runtest(int n, char const* filename1, char const* arg2) assert_compare_numbers(INT_MAX, t.getKey("/Q3").getIntValueAsInt()); assert_compare_numbers(UINT_MAX, t.getKey("/Q3").getUIntValueAsUInt()); } + else if (n == 63) + { + QPDFWriter w(pdf); + // Exercise setting encryption parameters before setting the + // output filename. The previous bug does not happen if static + // or deterministic ID is used because the filename is not + // used as part of the input data for ID generation in those + // cases. + w.setR6EncryptionParameters( + "u", "o", true, true, true, true, true, true, qpdf_r3p_full, true); + w.setOutputFilename("a.pdf"); + w.write(); + } else { throw std::runtime_error(std::string("invalid test ") + |