2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
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
13 use File::Spec::Functions qw/catfile/;
15 use File::Compare qw/compare_text/;
17 use OpenSSL::Test qw/:DEFAULT srctop_file/;
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.
24 my $testsrc = srctop_file("test","recipes",basename($0));
26 my $test = catfile(".", "p");
31 map { s/^\s+//; s/\s+$//; split /\s+/ }
32 run(app([$cmd, "list", "-cipher-commands"]), capture => 1);
34 plan tests => 1 + (scalar @ciphers)*2;
36 my $init = ok(copy($testsrc,$test));
39 diag("Trying to copy $testsrc to $test : $!");
43 skip "Not initialized, skipping...", 11 unless $init;
45 foreach my $c (@ciphers) {
46 my %variant = ("$c" => [],
47 "$c base64" => [ "-a" ]);
49 foreach my $t (sort keys %variant) {
50 my $cipherfile = "$test.$c.cipher";
51 my $clearfile = "$test.$c.clear";
52 my @e = ( "$c", "-bufsize", "113", @{$variant{$t}}, "-e", "-k", "test" );
53 my @d = ( "$c", "-bufsize", "157", @{$variant{$t}}, "-d", "-k", "test" );
55 $cipherfile = "$test.cipher";
56 $clearfile = "$test.clear";
57 @e = ( "enc", @{$variant{$t}}, "-e" );
58 @d = ( "enc", @{$variant{$t}}, "-d" );
61 ok(run(app([$cmd, @e, "-in", $test, "-out", $cipherfile]))
62 && run(app([$cmd, @d, "-in", $cipherfile, "-out", $clearfile]))
63 && compare_text($test,$clearfile) == 0, $t);
64 unlink $cipherfile, $clearfile;