Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: make and use a fipsinstall script #11565

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/fipsinstall.pl
@@ -0,0 +1,53 @@
#! /usr/bin/env perl

use strict;
use warnings;

use File::Spec;

use if $^O eq "VMS", "VMS::Filespec";

my $bldtop_dir;

# First script argument MUST be the build top directory
BEGIN {
$bldtop_dir = $ARGV[0];
# 'use lib' needs Unix-ish paths
$bldtop_dir = VMS::Filespec::unixpath($bldtop_dir) if $^O eq "VMS";
}

use lib $bldtop_dir;
use FindBin;
use lib "$FindBin::Bin/../Configurations";
use platform;

my @providers = ($bldtop_dir, 'providers');
my $fips_cnf = File::Spec->catfile(@providers, 'fipsinstall.cnf');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh. This is a a really bad name for the config file. It is about configuration of the FIPS module. I will update my "rename things" PR. :(

my $fips_module = File::Spec->catfile(@providers, platform->dso('fips'));
my $openssl = File::Spec->catfile($bldtop_dir, 'apps',
platform->bin('openssl'));

# We create the command like this to make it readable, then massage it with
# a space replacement regexp to make it usable with system()
my $cmd = <<_____;
$openssl fipsinstall \
-out "{fips_cnf}" \
-module "{fips_module}" \
-provider_name "fips" \
-mac_name "HMAC" -macopt "digest:SHA256" -macopt "hexkey:00" \
-section_name "fips_sect"
_____
$cmd =~ s|\s+| |gm;
$cmd =~ s|{fips_cnf}|$fips_cnf|;
$cmd =~ s|{fips_module}|$fips_module|;

my $exit = 0;
system($cmd);
die "Failed to run '$cmd'\n" if $? == -1;
# If there was a signal, use it as exit code with high bit set.
$exit = (($? & 255) | 128) if ($? & 255) != 0;
# Otherwise, just return fipsinstall's exit code
$exit = ($? >> 8);

exit($exit);

8 changes: 1 addition & 7 deletions test/recipes/30-test_evp.t
Expand Up @@ -79,16 +79,10 @@ plan tests =>
+ 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.cnf'),
'-module', $infile,
'-provider_name', 'fips', '-mac_name', 'HMAC',
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
'-section_name', 'fips_sect'])),
ok(run(perltest(['fipsinstall.pl', bldtop_dir()])),
"fipsinstall");
}

Expand Down
7 changes: 1 addition & 6 deletions test/recipes/30-test_evp_fetch_prov.t
Expand Up @@ -47,12 +47,7 @@ my @testdata = (

unless ($no_fips) {
push @setups, {
cmd => app(['openssl', 'fipsinstall',
'-out', bldtop_file('providers', 'fipsinstall.cnf'),
'-module', bldtop_file('providers', platform->dso('fips')),
'-provider_name', 'fips', '-mac_name', 'HMAC',
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
'-section_name', 'fips_sect']),
cmd => perltest(['fipsinstall.pl', bldtop_dir()]),
message => "fipsinstall"
};
push @testdata, (
Expand Down
7 changes: 1 addition & 6 deletions test/recipes/90-test_sslprovider.t
Expand Up @@ -30,12 +30,7 @@ SKIP: {
skip "Skipping FIPS installation", 1
if disabled("fips");

ok(run(app(['openssl', 'fipsinstall',
'-out', bldtop_file('providers', 'fipsinstall.cnf'),
'-module', bldtop_file('providers', platform->dso('fips')),
'-provider_name', 'fips', '-mac_name', 'HMAC',
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
'-section_name', 'fips_sect'])),
ok(run(perltest(['fipsinstall.pl', bldtop_dir()])),
"fipsinstall");
}

Expand Down