]>
Commit | Line | Data |
---|---|---|
596d6b7e RS |
1 | #! /usr/bin/env perl |
2 | # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. | |
3 | # | |
4 | # Licensed under the OpenSSL license (the "License"). You may not use | |
5 | # this file except in compliance with the License. You can obtain a copy | |
6 | # in the file LICENSE in the source distribution or at | |
7 | # https://www.openssl.org/source/license.html | |
8 | ||
13350a0c RL |
9 | |
10 | use strict; | |
11 | use warnings; | |
12 | ||
13 | use File::Spec::Functions qw/catfile/; | |
14 | use File::Copy; | |
15 | use File::Compare qw/compare_text/; | |
16 | use File::Basename; | |
42e0ccdf | 17 | use OpenSSL::Test qw/:DEFAULT srctop_file/; |
13350a0c RL |
18 | |
19 | setup("test_enc"); | |
20 | ||
21 | # We do it this way, because setup() may have moved us around, | |
22 | # so the directory portion of $0 might not be correct any more. | |
23 | # However, the name hasn't changed. | |
42e0ccdf | 24 | my $testsrc = srctop_file("test","recipes",basename($0)); |
13350a0c RL |
25 | |
26 | my $test = catfile(".", "p"); | |
27 | ||
28 | my $cmd = "openssl"; | |
29 | ||
30f1c9c4 | 30 | my $ciphersstatus = undef; |
13350a0c | 31 | my @ciphers = |
85833408 | 32 | map { s/^\s+//; s/\s+$//; split /\s+/ } |
30f1c9c4 RL |
33 | run(app([$cmd, "list", "-cipher-commands"]), |
34 | capture => 1, statusvar => \$ciphersstatus); | |
13350a0c | 35 | |
30f1c9c4 | 36 | plan tests => 2 + (scalar @ciphers)*2; |
13350a0c RL |
37 | |
38 | SKIP: { | |
30f1c9c4 RL |
39 | skip "Problems getting ciphers...", 1 + scalar(@ciphers) |
40 | unless ok($ciphersstatus, "Running 'openssl list -cipher-commands'"); | |
41 | unless (ok(copy($testsrc, $test), "Copying $testsrc to $test")) { | |
42 | diag($!); | |
43 | skip "Not initialized, skipping...", scalar(@ciphers); | |
44 | } | |
13350a0c RL |
45 | |
46 | foreach my $c (@ciphers) { | |
47 | my %variant = ("$c" => [], | |
48 | "$c base64" => [ "-a" ]); | |
49 | ||
50 | foreach my $t (sort keys %variant) { | |
51 | my $cipherfile = "$test.$c.cipher"; | |
52 | my $clearfile = "$test.$c.clear"; | |
53 | my @e = ( "$c", "-bufsize", "113", @{$variant{$t}}, "-e", "-k", "test" ); | |
54 | my @d = ( "$c", "-bufsize", "157", @{$variant{$t}}, "-d", "-k", "test" ); | |
55 | if ($c eq "cat") { | |
56 | $cipherfile = "$test.cipher"; | |
57 | $clearfile = "$test.clear"; | |
58 | @e = ( "enc", @{$variant{$t}}, "-e" ); | |
59 | @d = ( "enc", @{$variant{$t}}, "-d" ); | |
60 | } | |
61 | ||
9b56815d RL |
62 | ok(run(app([$cmd, @e, "-in", $test, "-out", $cipherfile])) |
63 | && run(app([$cmd, @d, "-in", $cipherfile, "-out", $clearfile])) | |
13350a0c RL |
64 | && compare_text($test,$clearfile) == 0, $t); |
65 | unlink $cipherfile, $clearfile; | |
66 | } | |
67 | } | |
68 | } | |
69 | ||
70 | unlink $test; |