2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
2020-04-23 20:55:52 +08:00
|
|
|
# Copyright 2015-2020 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 {
|
2020-08-07 12:29:00 +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
|
2020-08-30 15:53:22 +08:00
|
|
|
push @configs, 'fips-and-base.cnf' unless $no_fips;
|
2019-08-12 13:04:13 +08:00
|
|
|
|
2020-08-07 12:29:00 +08:00
|
|
|
# A list of tests that run with both the default and fips provider.
|
|
|
|
my @files = qw(
|
|
|
|
evpciph_aes_ccm_cavs.txt
|
|
|
|
evpciph_aes_common.txt
|
|
|
|
evpciph_aes_cts1.txt
|
|
|
|
evpciph_des3_common.txt
|
|
|
|
evpkdf_hkdf.txt
|
|
|
|
evpkdf_pbkdf2.txt
|
|
|
|
evpkdf_ss.txt
|
|
|
|
evpkdf_ssh.txt
|
|
|
|
evpkdf_tls12_prf.txt
|
|
|
|
evpkdf_x963.txt
|
|
|
|
evpmac_common.txt
|
|
|
|
evpmd_sha.txt
|
|
|
|
evppbe_pbkdf2.txt
|
|
|
|
evppkey_dsa.txt
|
2020-08-29 21:08:05 +08:00
|
|
|
evppkey_ecc.txt
|
|
|
|
evppkey_ecdh.txt
|
2020-08-07 12:29:00 +08:00
|
|
|
evppkey_ecdsa.txt
|
|
|
|
evppkey_ecx.txt
|
|
|
|
evppkey_ffdhe.txt
|
|
|
|
evppkey_kas.txt
|
|
|
|
evppkey_kdf_hkdf.txt
|
|
|
|
evppkey_mismatch.txt
|
|
|
|
evppkey_rsa.txt
|
|
|
|
evprand.txt
|
|
|
|
);
|
|
|
|
|
|
|
|
# A list of tests that only run with the default provider
|
|
|
|
# (i.e. The algorithms are not present in the fips provider)
|
|
|
|
my @defltfiles = qw(
|
|
|
|
evpciph_aes_cts23.txt
|
|
|
|
evpciph_aes_ocb.txt
|
|
|
|
evpciph_aes_siv.txt
|
|
|
|
evpciph_aria.txt
|
|
|
|
evpciph_bf.txt
|
|
|
|
evpciph_camellia.txt
|
|
|
|
evpciph_cast5.txt
|
|
|
|
evpciph_chacha.txt
|
|
|
|
evpciph_des.txt
|
|
|
|
evpciph_idea.txt
|
|
|
|
evpciph_rc2.txt
|
|
|
|
evpciph_rc4.txt
|
|
|
|
evpciph_rc5.txt
|
|
|
|
evpciph_seed.txt
|
|
|
|
evpciph_sm4.txt
|
|
|
|
evpencod.txt
|
|
|
|
evpkdf_krb5.txt
|
|
|
|
evpkdf_scrypt.txt
|
|
|
|
evpkdf_tls11_prf.txt
|
|
|
|
evpkdf_x942.txt
|
|
|
|
evpmac_blake.txt
|
|
|
|
evpmac_poly1305.txt
|
|
|
|
evpmac_siphash.txt
|
|
|
|
evpmd_blake.txt
|
|
|
|
evpmd_md.txt
|
|
|
|
evpmd_mdc2.txt
|
|
|
|
evpmd_ripemd.txt
|
|
|
|
evpmd_sm3.txt
|
|
|
|
evpmd_whirlpool.txt
|
|
|
|
evppbe_scrypt.txt
|
2020-08-11 11:19:40 +08:00
|
|
|
evppbe_pkcs12.txt
|
2020-08-07 12:29:00 +08:00
|
|
|
evppkey_brainpool.txt
|
|
|
|
evppkey_kdf_scrypt.txt
|
|
|
|
evppkey_kdf_tls1_prf.txt
|
|
|
|
evppkey_sm2.txt
|
|
|
|
);
|
2020-01-14 06:01:34 +08:00
|
|
|
|
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) {
|
2020-04-21 18:24:44 +08:00
|
|
|
my $infile = bldtop_file('providers', platform->dso('fips'));
|
2019-09-29 16:32:04 +08:00
|
|
|
|
2020-04-21 18:24:44 +08:00
|
|
|
ok(run(app(['openssl', 'fipsinstall',
|
2020-02-26 05:27:24 +08:00
|
|
|
'-out', bldtop_file('providers', 'fipsmodule.cnf'),
|
2020-06-29 09:11:48 +08:00
|
|
|
'-module', $infile])),
|
2019-11-23 15:54:29 +08:00
|
|
|
"fipsinstall");
|
2019-09-29 16:32:04 +08:00
|
|
|
}
|
2017-05-12 00:17:38 +08:00
|
|
|
|
2019-07-17 20:26:26 +08:00
|
|
|
foreach (@configs) {
|
2020-08-07 12:29:00 +08:00
|
|
|
my $conf = srctop_file("test", $_);
|
2019-07-17 20:26:26 +08:00
|
|
|
|
|
|
|
foreach my $f ( @files ) {
|
2020-08-07 12:29:00 +08:00
|
|
|
ok(run(test(["evp_test",
|
|
|
|
"-config", $conf,
|
|
|
|
data_file("$f")])),
|
|
|
|
"running evp_test -config $conf $f");
|
2019-07-17 20:26:26 +08:00
|
|
|
}
|
2017-05-12 00:17:38 +08:00
|
|
|
}
|
2019-08-05 20:38:25 +08:00
|
|
|
|
2020-08-07 12:29:00 +08:00
|
|
|
my $conf = srctop_file("test", $defaultcnf);
|
2019-08-05 20:38:25 +08:00
|
|
|
foreach my $f ( @defltfiles ) {
|
2020-08-07 12:29:00 +08:00
|
|
|
ok(run(test(["evp_test",
|
|
|
|
"-config", $conf,
|
|
|
|
data_file("$f")])),
|
|
|
|
"running evp_test -config $conf $f");
|
2019-08-05 20:38:25 +08:00
|
|
|
}
|