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/;
20 setup("test_evp_more");
22 my $testsrc = srctop_file("test", "recipes", basename($0));
24 my $cipherlist = undef;
25 my $plaintext = catfile(".", "testdatafile");
28 my $provpath = bldtop_dir("providers");
29 my @prov = ("-provider_path", $provpath, "-provider", "default", "-provider", "legacy");
31 my $ciphersstatus = undef;
33 grep(! /wrap|^$|^[^-]/,
35 run(app([$cmd, "enc", "-list"]),
36 capture => 1, statusvar => \$ciphersstatus)));
38 plan tests => 2 + scalar @ciphers;
41 skip "Problems getting ciphers...", 1 + scalar(@ciphers)
42 unless ok($ciphersstatus, "Running 'openssl enc -list'");
43 unless (ok(copy($testsrc, $plaintext), "Copying $testsrc to $plaintext")) {
45 skip "Not initialized, skipping...", scalar(@ciphers);
48 foreach my $cipher (@ciphers) {
49 my $ciphername = substr $cipher, 1;
50 my $cipherfile = "$plaintext.$ciphername.cipher";
51 my $clearfile = "$plaintext.$ciphername.clear";
52 my @common = ( $cmd, "enc", "$cipher", "-k", "test" );
54 ok(run(app([@common, @prov, "-e", "-in", $plaintext, "-out", $cipherfile]))
55 && compare_text($plaintext, $cipherfile) != 0
56 && run(app([@common, @prov, "-d", "-in", $cipherfile, "-out", $clearfile]))
57 && compare_text($plaintext, $clearfile) == 0