xref: /freebsd/crypto/openssl/test/recipes/30-test_defltfips.t (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#! /usr/bin/env perl
2*e0c4386eSCy Schubert# Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert#
4*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert
9*e0c4386eSCy Schubert
10*e0c4386eSCy Schubertuse strict;
11*e0c4386eSCy Schubertuse warnings;
12*e0c4386eSCy Schubert
13*e0c4386eSCy Schubertuse OpenSSL::Test qw/:DEFAULT srctop_file srctop_dir bldtop_file bldtop_dir data_dir/;
14*e0c4386eSCy Schubertuse OpenSSL::Test::Utils;
15*e0c4386eSCy Schubertuse Cwd qw(abs_path);
16*e0c4386eSCy Schubert
17*e0c4386eSCy SchubertBEGIN {
18*e0c4386eSCy Schubert    setup("test_defltfips");
19*e0c4386eSCy Schubert}
20*e0c4386eSCy Schubert
21*e0c4386eSCy Schubertuse lib srctop_dir('Configurations');
22*e0c4386eSCy Schubertuse lib bldtop_dir('.');
23*e0c4386eSCy Schubert
24*e0c4386eSCy Schubertplan skip_all => "Configuration loading is turned off"
25*e0c4386eSCy Schubert    if disabled("autoload-config");
26*e0c4386eSCy Schubert
27*e0c4386eSCy Schubertmy $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
28*e0c4386eSCy Schubert
29*e0c4386eSCy Schubertplan tests =>
30*e0c4386eSCy Schubert    ($no_fips ? 1 : 5);
31*e0c4386eSCy Schubert
32*e0c4386eSCy Schubertunless ($no_fips) {
33*e0c4386eSCy Schubert    $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips.cnf"));
34*e0c4386eSCy Schubert    ok(run(test(["defltfips_test", "fips"])), "running defltfips_test fips");
35*e0c4386eSCy Schubert
36*e0c4386eSCy Schubert    #Test an alternative way of configuring fips
37*e0c4386eSCy Schubert    $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips-alt.cnf"));
38*e0c4386eSCy Schubert    ok(run(test(["defltfips_test", "fips"])), "running defltfips_test fips");
39*e0c4386eSCy Schubert
40*e0c4386eSCy Schubert    #Configured to run FIPS but the module-mac is bad
41*e0c4386eSCy Schubert    $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips.cnf"));
42*e0c4386eSCy Schubert    $ENV{OPENSSL_CONF_INCLUDE} = srctop_dir("test", "recipes", "30-test_defltfips");
43*e0c4386eSCy Schubert    ok(run(test(["defltfips_test", "badfips"])), "running defltfips_test badfips");
44*e0c4386eSCy Schubert
45*e0c4386eSCy Schubert    #Test an alternative way of configuring fips (but still with bad module-mac)
46*e0c4386eSCy Schubert    $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips-alt.cnf"));
47*e0c4386eSCy Schubert    ok(run(test(["defltfips_test", "badfips"])), "running defltfips_test badfips");
48*e0c4386eSCy Schubert}
49*e0c4386eSCy Schubert
50*e0c4386eSCy Schubert$ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "default.cnf"));
51*e0c4386eSCy Schubertok(run(test(["defltfips_test"])), "running defltfips_test");
52