]>
Commit | Line | Data |
---|---|---|
13350a0c RL |
1 | #! /usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use File::Spec::Functions qw/catfile/; | |
7 | use File::Copy; | |
8 | use File::Compare qw/compare_text/; | |
9 | use File::Basename; | |
13350a0c RL |
10 | use OpenSSL::Test qw/:DEFAULT top_file/; |
11 | ||
12 | setup("test_enc"); | |
13 | ||
14 | # We do it this way, because setup() may have moved us around, | |
15 | # so the directory portion of $0 might not be correct any more. | |
16 | # However, the name hasn't changed. | |
17 | my $testsrc = top_file("test","recipes",basename($0)); | |
18 | ||
19 | my $test = catfile(".", "p"); | |
20 | ||
21 | my $cmd = "openssl"; | |
22 | ||
23 | my @ciphers = | |
85833408 | 24 | map { s/^\s+//; s/\s+$//; split /\s+/ } |
13350a0c RL |
25 | run(app([$cmd, "list", "-cipher-commands"]), capture => 1); |
26 | ||
27 | plan tests => 1 + (scalar @ciphers)*2; | |
28 | ||
29 | my $init = ok(copy($testsrc,$test)); | |
30 | ||
31 | if (!$init) { | |
32 | diag("Trying to copy $testsrc to $test : $!"); | |
33 | } | |
34 | ||
35 | SKIP: { | |
36 | skip "Not initialized, skipping...", 11 unless $init; | |
37 | ||
38 | foreach my $c (@ciphers) { | |
39 | my %variant = ("$c" => [], | |
40 | "$c base64" => [ "-a" ]); | |
41 | ||
42 | foreach my $t (sort keys %variant) { | |
43 | my $cipherfile = "$test.$c.cipher"; | |
44 | my $clearfile = "$test.$c.clear"; | |
45 | my @e = ( "$c", "-bufsize", "113", @{$variant{$t}}, "-e", "-k", "test" ); | |
46 | my @d = ( "$c", "-bufsize", "157", @{$variant{$t}}, "-d", "-k", "test" ); | |
47 | if ($c eq "cat") { | |
48 | $cipherfile = "$test.cipher"; | |
49 | $clearfile = "$test.clear"; | |
50 | @e = ( "enc", @{$variant{$t}}, "-e" ); | |
51 | @d = ( "enc", @{$variant{$t}}, "-d" ); | |
52 | } | |
53 | ||
9b56815d RL |
54 | ok(run(app([$cmd, @e, "-in", $test, "-out", $cipherfile])) |
55 | && run(app([$cmd, @d, "-in", $cipherfile, "-out", $clearfile])) | |
13350a0c RL |
56 | && compare_text($test,$clearfile) == 0, $t); |
57 | unlink $cipherfile, $clearfile; | |
58 | } | |
59 | } | |
60 | } | |
61 | ||
62 | unlink $test; |