blob: 1419ddb5c37d63c00d76bb96b05f19550aa20970 [file] [log] [blame]
Pauli227a44b2017-02-23 08:34:32 +10001#! /usr/bin/env perl
2# Copyright 2017 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#
9# ======================================================================
10# Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
11
12
13use strict;
14use warnings;
15
16use File::Spec::Functions qw/catfile/;
17use File::Copy;
18use File::Compare qw/compare_text/;
19use File::Basename;
20use OpenSSL::Test qw/:DEFAULT srctop_file/;
21
22setup("test_evp_more");
23
24my $testsrc = srctop_file("test", "recipes", basename($0));
25
26my $cipherlist = undef;
27my $plaintext = catfile(".", "testdatafile");
28my $fail = "";
29my $cmd = "openssl";
30
31my @ciphers =
Pauli777f1702017-03-08 11:18:55 +100032 grep(! /wrap|^$|^[^-]/,
Pauli227a44b2017-02-23 08:34:32 +100033 (map { split /\s+/ }
34 run(app([$cmd, "enc", "-ciphers"]), capture => 1)));
35
36plan tests => 1 + scalar @ciphers;
37
38my $init = ok(copy($testsrc, $plaintext));
39
40SKIP: {
41 skip "Not initialized, skipping...", (scalar @ciphers) unless $init;
42
43 foreach my $cipher (@ciphers) {
44 my $ciphername = substr $cipher, 1;
45 my $cipherfile = "$plaintext.$ciphername.cipher";
46 my $clearfile = "$plaintext.$ciphername.clear";
47 my @common = ( $cmd, "enc", "$cipher", "-k", "test" );
48
49 ok(run(app([@common, "-e", "-in", $plaintext, "-out", $cipherfile]))
50 && compare_text($plaintext, $cipherfile) != 0
51 && run(app([@common, "-d", "-in", $cipherfile, "-out", $clearfile]))
52 && compare_text($plaintext, $clearfile) == 0
53 , $ciphername);
54 unlink $cipherfile, $clearfile;
55 }
56}
57
58unlink $plaintext;