From 0a3057dc0a1b77720cf560a2644ed039dd46bd6a Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 19 Jan 2019 14:11:53 -0500 Subject: More testing for Unicode passwords --- qpdf/qtest/qpdf.test | 20 +++++++++++++++++++- qpdf/qtest/qpdf/unicode-op.out | 15 +++++++++++++++ qpdf/qtest/qpdf/unicode-up.out | 15 +++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 qpdf/qtest/qpdf/unicode-op.out create mode 100644 qpdf/qtest/qpdf/unicode-up.out diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 1ccd4d12..a31d463d 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -3378,7 +3378,8 @@ foreach my $d (@unicode_pw_cases) } } -$n_tests += 2; +$n_tests += 5; + $td->runtest("bytes fallback warning", {$td->COMMAND => "qpdf --encrypt \@password-bare-complex-utf8 o 128 --" . @@ -3402,6 +3403,23 @@ $td->runtest("bytes fallback warning", $td->NORMALIZE_NEWLINES); } +# Exercise passing Unicode passwords via the command line. This tests +# wmain for Windows and assumes a UTF-8 locale for other platforms. +$td->runtest("Unicode at CLI", + {$td->COMMAND => + "qpdf --encrypt π ʬ 256 --" . + " minimal.pdf a.pdf"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("Decrypt using user password", + {$td->COMMAND => "qpdf --show-encryption a.pdf --password=π"}, + {$td->FILE => "unicode-up.out", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("Decrypt using owner password", + {$td->COMMAND => "qpdf --show-encryption a.pdf --password=ʬ"}, + {$td->FILE => "unicode-op.out", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); + show_ntests(); # ---------- $td->notify("--- Check from C API ---"); diff --git a/qpdf/qtest/qpdf/unicode-op.out b/qpdf/qtest/qpdf/unicode-op.out new file mode 100644 index 00000000..a1437ca4 --- /dev/null +++ b/qpdf/qtest/qpdf/unicode-op.out @@ -0,0 +1,15 @@ +R = 6 +P = -4 +User password = +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 diff --git a/qpdf/qtest/qpdf/unicode-up.out b/qpdf/qtest/qpdf/unicode-up.out new file mode 100644 index 00000000..9e3a0581 --- /dev/null +++ b/qpdf/qtest/qpdf/unicode-up.out @@ -0,0 +1,15 @@ +R = 6 +P = -4 +User password = π +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 -- cgit v1.2.3-70-g09d2