2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
2018-09-11 20:22:14 +08:00
|
|
|
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2016-04-22 19:21:51 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-04-22 19:21:51 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2015-04-18 02:16:13 +08:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2019-09-15 17:55:10 +08:00
|
|
|
use OpenSSL::Test qw(:DEFAULT data_file bldtop_dir srctop_file srctop_dir bldtop_file);
|
2019-08-12 13:04:13 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
2015-04-18 02:16:13 +08:00
|
|
|
|
2019-09-15 17:55:10 +08:00
|
|
|
BEGIN {
|
2015-04-18 02:16:13 +08:00
|
|
|
setup("test_evp");
|
2019-09-15 17:55:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
use lib srctop_dir('Configurations');
|
|
|
|
use lib bldtop_dir('.');
|
|
|
|
use platform;
|
2015-04-18 02:16:13 +08:00
|
|
|
|
2019-09-29 16:32:04 +08:00
|
|
|
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
|
|
|
|
my $no_legacy = disabled('legacy') || ($ENV{NO_LEGACY} // 0);
|
|
|
|
|
2019-08-12 13:04:13 +08:00
|
|
|
# Default config depends on if the legacy module is built or not
|
2019-09-29 16:32:04 +08:00
|
|
|
my $defaultcnf = $no_legacy ? 'default.cnf' : 'default-and-legacy.cnf';
|
2019-08-12 13:04:13 +08:00
|
|
|
|
|
|
|
my @configs = ( $defaultcnf );
|
|
|
|
# Only add the FIPS config if the FIPS module has been built
|
2019-09-29 16:32:04 +08:00
|
|
|
push @configs, 'fips.cnf' unless $no_fips;
|
2019-08-12 13:04:13 +08:00
|
|
|
|
2019-08-05 20:38:25 +08:00
|
|
|
my @files = qw( evpciph.txt evpdigest.txt );
|
|
|
|
my @defltfiles = qw( evpencod.txt evpkdf.txt evppkey_kdf.txt evpmac.txt
|
2019-11-08 10:14:44 +08:00
|
|
|
evppbe.txt evppkey.txt evppkey_ecc.txt evpcase.txt evpccmcavs.txt );
|
2019-09-18 13:57:08 +08:00
|
|
|
my @ideafiles = qw( evpciph_idea.txt );
|
|
|
|
push @defltfiles, @ideafiles unless disabled("idea");
|
2017-05-12 00:17:38 +08:00
|
|
|
|
2019-11-08 10:14:44 +08:00
|
|
|
my @sivfiles = qw( evpaessiv.txt );
|
|
|
|
push @defltfiles, @sivfiles unless disabled("siv");
|
|
|
|
|
2019-09-18 16:55:11 +08:00
|
|
|
my @castfiles = qw( evpciph_cast5.txt );
|
|
|
|
push @defltfiles, @castfiles unless disabled("cast");
|
|
|
|
|
2019-09-18 20:13:59 +08:00
|
|
|
my @seedfiles = qw( evpciph_seed.txt );
|
|
|
|
push @defltfiles, @seedfiles unless disabled("seed");
|
|
|
|
|
2019-09-19 13:38:51 +08:00
|
|
|
my @sm4files = qw( evpciph_sm4.txt );
|
|
|
|
push @defltfiles, @sm4files unless disabled("sm4");
|
|
|
|
|
2019-09-23 12:35:16 +08:00
|
|
|
my @desfiles = qw( evpciph_des.txt );
|
|
|
|
push @defltfiles, @desfiles unless disabled("des");
|
|
|
|
|
2019-09-25 08:46:39 +08:00
|
|
|
my @rc4files = qw( evpciph_rc4.txt );
|
|
|
|
push @defltfiles, @rc4files unless disabled("rc4");
|
|
|
|
|
2019-10-03 14:05:49 +08:00
|
|
|
my @rc5files = qw( evpciph_rc5.txt );
|
|
|
|
push @defltfiles, @rc5files unless disabled("rc5");
|
|
|
|
|
2019-10-08 14:42:28 +08:00
|
|
|
my @rc2files = qw( evpciph_rc2.txt );
|
|
|
|
push @defltfiles, @rc2files unless disabled("rc2");
|
|
|
|
|
2019-10-16 14:18:42 +08:00
|
|
|
my @chachafiles = qw( evpciph_chacha.txt );
|
|
|
|
push @defltfiles, @chachafiles unless disabled("chacha");
|
|
|
|
|
2019-11-15 22:15:09 +08:00
|
|
|
my @bffiles = qw( evpciph_bf.txt );
|
|
|
|
push @defltfiles, @bffiles unless disabled("bf");
|
|
|
|
|
2019-09-29 16:32:04 +08:00
|
|
|
plan tests =>
|
|
|
|
($no_fips ? 0 : 1) # FIPS install test
|
|
|
|
+ (scalar(@configs) * scalar(@files))
|
|
|
|
+ scalar(@defltfiles);
|
|
|
|
|
|
|
|
unless ($no_fips) {
|
|
|
|
my $infile = bldtop_file('providers', platform->dso('fips'));
|
|
|
|
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
|
|
|
|
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
|
|
|
|
|
|
|
|
ok(run(app(['openssl', 'fipsinstall',
|
|
|
|
'-out', bldtop_file('providers', 'fipsinstall.conf'),
|
|
|
|
'-module', $infile,
|
|
|
|
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
|
|
|
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
|
|
|
'-section_name', 'fips_sect'])),
|
|
|
|
"fipinstall");
|
|
|
|
}
|
2017-05-12 00:17:38 +08:00
|
|
|
|
2019-07-17 20:26:26 +08:00
|
|
|
foreach (@configs) {
|
|
|
|
$ENV{OPENSSL_CONF} = srctop_file("test", $_);
|
|
|
|
|
|
|
|
foreach my $f ( @files ) {
|
|
|
|
ok(run(test(["evp_test", data_file("$f")])),
|
|
|
|
"running evp_test $f");
|
|
|
|
}
|
2017-05-12 00:17:38 +08:00
|
|
|
}
|
2019-08-05 20:38:25 +08:00
|
|
|
|
|
|
|
#TODO(3.0): As more operations are converted to providers we can move more of
|
|
|
|
# these tests to the loop above
|
|
|
|
|
2019-08-12 13:04:13 +08:00
|
|
|
$ENV{OPENSSL_CONF} = srctop_file("test", $defaultcnf);
|
2019-08-05 20:38:25 +08:00
|
|
|
|
|
|
|
foreach my $f ( @defltfiles ) {
|
|
|
|
ok(run(test(["evp_test", data_file("$f")])),
|
|
|
|
"running evp_test $f");
|
|
|
|
}
|