2 # Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
3 # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
5 # Licensed under the Apache License 2.0 (the "License"). You may not use
6 # this file except in compliance with the License. You can obtain a copy
7 # in the file LICENSE in the source distribution or at
8 # https://www.openssl.org/source/license.html
14 use File::Spec::Functions qw/catfile/;
16 use File::Compare qw/compare_text/;
18 use OpenSSL::Test qw/:DEFAULT srctop_file bldtop_dir/;
19 use OpenSSL::Test::Utils;
22 setup("test_evp_more");
24 my $testsrc = srctop_file("test", "recipes", basename($0));
26 my $cipherlist = undef;
27 my $plaintext = catfile(".", "testdatafile");
30 my $provpath = bldtop_dir("providers");
31 my @prov = ("-provider-path", $provpath, "-provider", "default");
32 push @prov, ("-provider", "legacy") unless disabled("legacy");
34 my $ciphersstatus = undef;
36 grep(! /wrap|^$|^[^-]/,
38 run(app([$cmd, "enc", "-list"]),
39 capture => 1, statusvar => \$ciphersstatus)));
40 @ciphers = grep {!/^-(bf|blowfish|cast|des$|des-cbc|des-cfb|des-ecb|des-ofb
41 |desx|idea|rc2|rc4|seed)/x} @ciphers
42 if disabled("legacy");
44 plan tests => 2 + scalar @ciphers;
47 skip "Problems getting ciphers...", 1 + scalar(@ciphers)
48 unless ok($ciphersstatus, "Running 'openssl enc -list'");
49 unless (ok(copy($testsrc, $plaintext), "Copying $testsrc to $plaintext")) {
51 skip "Not initialized, skipping...", scalar(@ciphers);
54 foreach my $cipher (@ciphers) {
55 my $ciphername = substr $cipher, 1;
56 my $cipherfile = "$plaintext.$ciphername.cipher";
57 my $clearfile = "$plaintext.$ciphername.clear";
58 my @common = ( $cmd, "enc", "$cipher", "-k", "test" );
60 ok(run(app([@common, @prov, "-e", "-in", $plaintext, "-out", $cipherfile]))
61 && compare_text($plaintext, $cipherfile) != 0
62 && run(app([@common, @prov, "-d", "-in", $cipherfile, "-out", $clearfile]))
63 && compare_text($plaintext, $clearfile) == 0