aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/weak-cryptography.test
blob: baf301ea50d61806f1c39298b50d1ea961c891e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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 --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 --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 --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 --bits=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);