]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/30-test_evp_fetch_prov.t
2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
12 use OpenSSL
::Test
qw(:DEFAULT bldtop_dir srctop_file srctop_dir bldtop_file);
13 use OpenSSL
::Test
::Utils
;
16 setup
("test_evp_fetch_prov");
19 use lib srctop_dir
('Configurations');
20 use lib bldtop_dir
('.');
23 my $no_fips = disabled
('fips') || ($ENV{NO_FIPS
} // 0);
25 my @types = ( "digest", "cipher" );
27 $ENV{OPENSSL_MODULES
} = bldtop_dir
("providers");
28 $ENV{OPENSSL_CONF_INCLUDE
} = bldtop_dir
("providers");
32 { config
=> srctop_file
("test", "default.cnf"),
33 providers
=> [ 'default' ],
34 tests
=> [ { providers
=> [] },
36 { args
=> [ '-property', 'default=yes' ],
37 message
=> 'using property "default=yes"' },
38 { args
=> [ '-property', 'fips=no' ],
39 message
=> 'using property "fips=no"' },
40 { args
=> [ '-property', 'default=no', '-fetchfail' ],
42 'using property "default=no" is expected to fail' },
43 { args
=> [ '-property', 'fips=yes', '-fetchfail' ],
45 'using property "fips=yes" is expected to fail' } ] }
50 cmd
=> app
(['openssl', 'fipsinstall',
51 '-out', bldtop_file
('providers', 'fipsinstall.conf'),
52 '-module', bldtop_file
('providers', platform
->dso('fips')),
53 '-provider_name', 'fips', '-mac_name', 'HMAC',
54 '-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
55 '-section_name', 'fips_sect']),
56 message
=> "fipsinstall"
59 { config
=> srctop_file
("test", "fips.cnf"),
60 providers
=> [ 'fips' ],
62 { args
=> [ '-property', '' ] },
63 { args
=> [ '-property', 'fips=yes' ],
64 message
=> 'using property "fips=yes"' },
65 { args
=> [ '-property', 'default=no' ],
66 message
=> 'using property "default = no"' },
67 { args
=> [ '-property', 'default=yes', '-fetchfail' ],
69 'using property "default=yes" is expected to fail' },
70 { args
=> [ '-property', 'fips=no', '-fetchfail' ],
72 'using property "fips=no" is expected to fail' } ] },
73 { config
=> srctop_file
("test", "default-and-fips.cnf"),
74 providers
=> [ 'default', 'fips' ],
76 { args
=> [ '-property', '' ] },
77 { args
=> [ '-property', 'default=no' ],
78 message
=> 'using property "default=no"' },
79 { args
=> [ '-property', 'default=yes' ],
80 message
=> 'using property "default=yes"' },
81 { args
=> [ '-property', 'fips=no' ],
82 message
=> 'using property "fips=no"' },
83 { args
=> [ '-property', 'fips=yes' ],
84 message
=> 'using property "fips=yes"' } ] }
90 $testcount += scalar @
{$_->{tests
}};
93 plan tests
=> 1 + scalar @setups + $testcount * scalar(@types);
95 ok
(run
(test
(["evp_fetch_prov_test", "-defaultctx"])),
96 "running evp_fetch_prov_test using the default libctx");
98 foreach my $setup (@setups) {
99 ok
(run
($setup->{cmd
}), $setup->{message
});
102 foreach my $alg (@types) {
103 foreach my $testcase (@testdata) {
104 $ENV{OPENSSL_CONF
} = $testcase->{config
};
105 foreach my $test (@
{$testcase->{tests
}}) {
107 @
{ $test->{providers
} // $testcase->{providers
} };
108 my $testprovstr = @testproviders
109 ?
' and loaded providers ' . join(' & ',
110 map { "'$_'" } @testproviders)
112 my @testargs = @
{ $test->{args
} // [] };
114 defined $test->{message
} ?
' '.$test->{message
} : '';
117 "running evp_fetch_prov_test with $alg$testprovstr$testmsg";
119 ok
(run
(test
(["evp_fetch_prov_test", "-type", "$alg",
120 @testargs, @testproviders])),