mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Arbitrarily use new --encrypt syntax for some tests
Now the tests intermix old and new syntax, ensuring both are exercised.
This commit is contained in:
parent
7d7e2234a5
commit
a2c4a2b12a
@ -31,7 +31,7 @@ foreach my $f (qw(compressed-metadata.pdf enc-base.pdf))
|
||||
$td->runtest("encrypt normally",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --allow-weak-crypto" .
|
||||
" --encrypt '' o 128 -- a.pdf b.pdf"},
|
||||
" --encrypt --owner-password=o --bits=128 -- a.pdf b.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0});
|
||||
check_metadata($td, "b.pdf", 1, 0);
|
||||
unlink "b.pdf";
|
||||
@ -45,7 +45,7 @@ foreach my $f (qw(compressed-metadata.pdf enc-base.pdf))
|
||||
$td->runtest("encrypt with cleartext metadata",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --allow-weak-crypto" .
|
||||
" --encrypt '' o 128 --cleartext-metadata --" .
|
||||
" --encrypt --owner-password=o --bits=128 --cleartext-metadata --" .
|
||||
" a.pdf b.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0});
|
||||
check_metadata($td, "b.pdf", 1, 1);
|
||||
|
@ -24,7 +24,7 @@ foreach my $file (qw(short-id long-id))
|
||||
$td->runtest("encrypt $file.pdf",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --allow-weak-crypto".
|
||||
" --encrypt '' pass 40 -- $file.pdf a.pdf"},
|
||||
" --encrypt --owner-password=pass --bits=40 -- $file.pdf a.pdf"},
|
||||
{$td->STRING => "",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
@ -135,7 +135,7 @@ $td->runtest("empty owner password",
|
||||
$td->EXIT_STATUS => 2},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("allow insecure",
|
||||
{$td->COMMAND => "qpdf --encrypt u '' 256 --allow-insecure --" .
|
||||
{$td->COMMAND => "qpdf --encrypt --user-password=u --bits=256 --allow-insecure --" .
|
||||
" minimal.pdf a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
@ -561,7 +561,7 @@ foreach my $d (['--force-V4', 'V4'],
|
||||
my ($args, $out) = @$d;
|
||||
$td->runtest("encrypt $args",
|
||||
{$td->COMMAND => "qpdf --static-aes-iv --static-id" .
|
||||
" --allow-weak-crypto --encrypt '' '' 128 $args --" .
|
||||
" --allow-weak-crypto --encrypt --bits=128 $args --" .
|
||||
" enc-base.pdf a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0});
|
||||
$td->runtest("check output",
|
||||
|
@ -71,7 +71,7 @@ foreach my $i (qw(40 128 256))
|
||||
}
|
||||
$td->runtest("encrypt $i",
|
||||
{$td->COMMAND =>
|
||||
"qpdf $x --encrypt '' o $i --" .
|
||||
"qpdf $x --encrypt --owner-password=o --bits=$i --" .
|
||||
" digitally-signed.pdf a.pdf"},
|
||||
{$td->STRING => "",
|
||||
$td->EXIT_STATUS => 0});
|
||||
@ -102,7 +102,7 @@ foreach my $i (qw(40 128 256))
|
||||
}
|
||||
$td->runtest("non sig dict encrypt $i",
|
||||
{$td->COMMAND =>
|
||||
"qpdf $x --encrypt '' o $i --" .
|
||||
"qpdf $x --encrypt --owner-password=o --bits=$i --" .
|
||||
" comment-annotation.pdf a.pdf"},
|
||||
{$td->STRING => "",
|
||||
$td->EXIT_STATUS => 0});
|
||||
|
@ -17,21 +17,21 @@ my $td = new TestDriver('weak-cryptography-cryptography');
|
||||
my $n_tests = 4;
|
||||
|
||||
$td->runtest("256-bit: no warning",
|
||||
{$td->COMMAND => 'qpdf --encrypt "" "" 256 -- minimal.pdf a.pdf'},
|
||||
{$td->COMMAND => 'qpdf --encrypt --bits=256 -- minimal.pdf a.pdf'},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("128-bit with AES: no warning",
|
||||
{$td->COMMAND => 'qpdf --encrypt "" "" 128 --use-aes=y --' .
|
||||
{$td->COMMAND => 'qpdf --encrypt --bits=128 --use-aes=y --' .
|
||||
' minimal.pdf a.pdf'},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("128-bit without AES: error",
|
||||
{$td->COMMAND => 'qpdf --encrypt "" "" 128 -- minimal.pdf a.pdf'},
|
||||
{$td->COMMAND => 'qpdf --encrypt --bits=128 -- minimal.pdf a.pdf'},
|
||||
{$td->REGEXP => "Pass --allow-weak-crypto to enable",
|
||||
$td->EXIT_STATUS => 2},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("40-bit: error",
|
||||
{$td->COMMAND => 'qpdf --encrypt "" "" 40 -- minimal.pdf a.pdf'},
|
||||
{$td->COMMAND => 'qpdf --encrypt --bits=40 -- minimal.pdf a.pdf'},
|
||||
{$td->REGEXP => "Pass --allow-weak-crypto to enable",
|
||||
$td->EXIT_STATUS => 2},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
Loading…
Reference in New Issue
Block a user