2008-04-29 12:55:25 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
require 5.008;
|
|
|
|
BEGIN { $^W = 1; }
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
chdir("rc4") or die "chdir testdir failed: $!\n";
|
|
|
|
|
|
|
|
require TestDriver;
|
|
|
|
|
|
|
|
my $td = new TestDriver('RC4');
|
|
|
|
|
2019-11-06 02:29:34 +00:00
|
|
|
my @providers = ();
|
|
|
|
if (exists $ENV{'QPDF_CRYPTO_PROVIDER'})
|
|
|
|
{
|
|
|
|
push(@providers, $ENV{'QPDF_CRYPTO_PROVIDER'});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
open(Q, "qpdf --show-crypto|") or die;
|
|
|
|
while (<Q>)
|
|
|
|
{
|
|
|
|
s/\s+$//s;
|
|
|
|
push(@providers, $_);
|
|
|
|
}
|
|
|
|
close(Q);
|
|
|
|
}
|
2008-04-29 12:55:25 +00:00
|
|
|
my @tests = ('0123456789abcdef',
|
2019-11-06 02:29:34 +00:00
|
|
|
'0123456789abcdef',
|
|
|
|
'0000000000000000',
|
|
|
|
'ef012345',
|
|
|
|
'0123456789abcdef');
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2019-11-06 02:29:34 +00:00
|
|
|
foreach my $p (@providers)
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
2019-11-06 02:29:34 +00:00
|
|
|
$ENV{'QPDF_CRYPTO_PROVIDER'} = $p;
|
|
|
|
|
|
|
|
cleanup();
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2019-11-06 02:29:34 +00:00
|
|
|
my $n = 0;
|
|
|
|
foreach my $key (@tests)
|
|
|
|
{
|
|
|
|
++$n;
|
|
|
|
$td->runtest("test $n ($p)",
|
|
|
|
{$td->COMMAND => "rc4 $key test$n.in tmp1-$n.out"},
|
|
|
|
{$td->STRING => "", $td->EXIT_STATUS => 0});
|
|
|
|
$td->runtest("check output",
|
|
|
|
{$td->FILE => "tmp1-$n.out"},
|
|
|
|
{$td->FILE => "test$n.out"});
|
|
|
|
$td->runtest("test $n reverse ($p)",
|
|
|
|
{$td->COMMAND => "rc4 $key test$n.out tmp2-$n.out"},
|
|
|
|
{$td->STRING => "", $td->EXIT_STATUS => 0});
|
|
|
|
$td->runtest("check output",
|
|
|
|
{$td->FILE => "tmp2-$n.out"},
|
|
|
|
{$td->FILE => "test$n.in"});
|
|
|
|
}
|
2019-11-05 23:44:16 +00:00
|
|
|
|
2019-11-06 02:29:34 +00:00
|
|
|
$td->runtest("other tests ($p)",
|
|
|
|
{$td->COMMAND => "rc4 other"},
|
|
|
|
{$td->STRING => "passed\n", $td->EXIT_STATUS => 0},
|
|
|
|
$td->NORMALIZE_NEWLINES);
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
}
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2019-11-06 02:29:34 +00:00
|
|
|
$td->report((1 + (4 * scalar(@tests))) * scalar(@providers));
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
sub cleanup
|
|
|
|
{
|
|
|
|
system("rm -f tmp*-*");
|
|
|
|
}
|