aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/weak_cryptography.test
diff options
context:
space:
mode:
Diffstat (limited to 'qpdf/qtest/weak_cryptography.test')
-rw-r--r--qpdf/qtest/weak_cryptography.test40
1 files changed, 40 insertions, 0 deletions
diff --git a/qpdf/qtest/weak_cryptography.test b/qpdf/qtest/weak_cryptography.test
new file mode 100644
index 00000000..c7491a0e
--- /dev/null
+++ b/qpdf/qtest/weak_cryptography.test
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl
+require 5.008;
+use warnings;
+use strict;
+
+unshift(@INC, '.');
+require qpdf_test_helpers;
+
+chdir("qpdf") or die "chdir testdir failed: $!\n";
+
+require TestDriver;
+
+cleanup();
+
+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->STRING => "", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("128-bit with AES: no warning",
+ {$td->COMMAND => 'qpdf --encrypt "" "" 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->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->REGEXP => "Pass --allow-weak-crypto to enable",
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
+
+cleanup();
+$td->report($n_tests);