]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/fipsinstall.pl
Teach ssl_test_new how to test the FIPS module
[thirdparty/openssl.git] / test / fipsinstall.pl
CommitLineData
ae6b654b
RL
1#! /usr/bin/env perl
2
3use strict;
4use warnings;
5
6use File::Spec;
7
8use if $^O eq "VMS", "VMS::Filespec";
9
10my $bldtop_dir;
11
12# First script argument MUST be the build top directory
13BEGIN {
14 $bldtop_dir = $ARGV[0];
15 # 'use lib' needs Unix-ish paths
16 $bldtop_dir = VMS::Filespec::unixpath($bldtop_dir) if $^O eq "VMS";
17}
18
19use lib $bldtop_dir;
20use FindBin;
21use lib "$FindBin::Bin/../Configurations";
22use platform;
23
24my @providers = ($bldtop_dir, 'providers');
25my $fips_cnf = File::Spec->catfile(@providers, 'fipsinstall.cnf');
26my $fips_module = File::Spec->catfile(@providers, platform->dso('fips'));
27my $openssl = File::Spec->catfile($bldtop_dir, 'apps',
28 platform->bin('openssl'));
29
30# We create the command like this to make it readable, then massage it with
31# a space replacement regexp to make it usable with system()
32my $cmd = <<_____;
33$openssl fipsinstall \
34 -out "{fips_cnf}" \
35 -module "{fips_module}" \
36 -provider_name "fips" \
37 -mac_name "HMAC" -macopt "digest:SHA256" -macopt "hexkey:00" \
38 -section_name "fips_sect"
39_____
40$cmd =~ s|\s+| |gm;
41$cmd =~ s|{fips_cnf}|$fips_cnf|;
42$cmd =~ s|{fips_module}|$fips_module|;
43
44my $exit = 0;
45system($cmd);
46die "Failed to run '$cmd'\n" if $? == -1;
47# If there was a signal, use it as exit code with high bit set.
48$exit = (($? & 255) | 128) if ($? & 255) != 0;
49# Otherwise, just return fipsinstall's exit code
50$exit = ($? >> 8);
51
52exit($exit);
53