]>
Commit | Line | Data |
---|---|---|
596d6b7e | 1 | #! /usr/bin/env perl |
1212818e | 2 | # Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. |
596d6b7e | 3 | # |
909f1a2e | 4 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
596d6b7e RS |
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 | |
8 | ||
4fb35f8f RL |
9 | |
10 | use strict; | |
11 | use warnings; | |
12 | ||
7bb82f92 | 13 | use OpenSSL::Test qw(:DEFAULT data_file bldtop_dir srctop_file srctop_dir bldtop_file); |
23ccf13d | 14 | use OpenSSL::Test::Utils; |
4fb35f8f | 15 | |
7bb82f92 | 16 | BEGIN { |
4fb35f8f | 17 | setup("test_evp"); |
7bb82f92 SL |
18 | } |
19 | ||
20 | use lib srctop_dir('Configurations'); | |
21 | use lib bldtop_dir('.'); | |
22 | use platform; | |
4fb35f8f | 23 | |
e0d952fc RL |
24 | my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0); |
25 | my $no_legacy = disabled('legacy') || ($ENV{NO_LEGACY} // 0); | |
26 | ||
23ccf13d | 27 | # Default config depends on if the legacy module is built or not |
e0d952fc | 28 | my $defaultcnf = $no_legacy ? 'default.cnf' : 'default-and-legacy.cnf'; |
23ccf13d RL |
29 | |
30 | my @configs = ( $defaultcnf ); | |
31 | # Only add the FIPS config if the FIPS module has been built | |
e0d952fc | 32 | push @configs, 'fips.cnf' unless $no_fips; |
23ccf13d | 33 | |
f305ecda MC |
34 | my @files = qw( evpciph.txt evpdigest.txt ); |
35 | my @defltfiles = qw( evpencod.txt evpkdf.txt evppkey_kdf.txt evpmac.txt | |
eb173822 | 36 | evppbe.txt evppkey.txt evppkey_ecc.txt evpcase.txt evpccmcavs.txt ); |
f22431f2 SL |
37 | my @ideafiles = qw( evpciph_idea.txt ); |
38 | push @defltfiles, @ideafiles unless disabled("idea"); | |
6b7b3433 | 39 | |
eb173822 SL |
40 | my @sivfiles = qw( evpaessiv.txt ); |
41 | push @defltfiles, @sivfiles unless disabled("siv"); | |
42 | ||
18b00427 SL |
43 | my @castfiles = qw( evpciph_cast5.txt ); |
44 | push @defltfiles, @castfiles unless disabled("cast"); | |
45 | ||
70adc646 SL |
46 | my @seedfiles = qw( evpciph_seed.txt ); |
47 | push @defltfiles, @seedfiles unless disabled("seed"); | |
48 | ||
105dde25 SL |
49 | my @sm4files = qw( evpciph_sm4.txt ); |
50 | push @defltfiles, @sm4files unless disabled("sm4"); | |
51 | ||
e3f3ee44 SL |
52 | my @desfiles = qw( evpciph_des.txt ); |
53 | push @defltfiles, @desfiles unless disabled("des"); | |
54 | ||
bafde183 SL |
55 | my @rc4files = qw( evpciph_rc4.txt ); |
56 | push @defltfiles, @rc4files unless disabled("rc4"); | |
57 | ||
6a41156c SL |
58 | my @rc5files = qw( evpciph_rc5.txt ); |
59 | push @defltfiles, @rc5files unless disabled("rc5"); | |
60 | ||
f816aa47 SL |
61 | my @rc2files = qw( evpciph_rc2.txt ); |
62 | push @defltfiles, @rc2files unless disabled("rc2"); | |
63 | ||
3d5a7578 SL |
64 | my @chachafiles = qw( evpciph_chacha.txt ); |
65 | push @defltfiles, @chachafiles unless disabled("chacha"); | |
66 | ||
18385800 MC |
67 | my @bffiles = qw( evpciph_bf.txt ); |
68 | push @defltfiles, @bffiles unless disabled("bf"); | |
69 | ||
e0d952fc RL |
70 | plan tests => |
71 | ($no_fips ? 0 : 1) # FIPS install test | |
72 | + (scalar(@configs) * scalar(@files)) | |
73 | + scalar(@defltfiles); | |
74 | ||
75 | unless ($no_fips) { | |
76 | my $infile = bldtop_file('providers', platform->dso('fips')); | |
77 | $ENV{OPENSSL_MODULES} = bldtop_dir("providers"); | |
78 | $ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers"); | |
79 | ||
80 | ok(run(app(['openssl', 'fipsinstall', | |
81 | '-out', bldtop_file('providers', 'fipsinstall.conf'), | |
82 | '-module', $infile, | |
83 | '-provider_name', 'fips', '-mac_name', 'HMAC', | |
84 | '-macopt', 'digest:SHA256', '-macopt', 'hexkey:00', | |
85 | '-section_name', 'fips_sect'])), | |
be3acd79 | 86 | "fipsinstall"); |
e0d952fc | 87 | } |
6b7b3433 | 88 | |
e2f72313 RL |
89 | foreach (@configs) { |
90 | $ENV{OPENSSL_CONF} = srctop_file("test", $_); | |
91 | ||
92 | foreach my $f ( @files ) { | |
93 | ok(run(test(["evp_test", data_file("$f")])), | |
94 | "running evp_test $f"); | |
95 | } | |
6b7b3433 | 96 | } |
f305ecda MC |
97 | |
98 | #TODO(3.0): As more operations are converted to providers we can move more of | |
99 | # these tests to the loop above | |
100 | ||
23ccf13d | 101 | $ENV{OPENSSL_CONF} = srctop_file("test", $defaultcnf); |
f305ecda MC |
102 | |
103 | foreach my $f ( @defltfiles ) { | |
104 | ok(run(test(["evp_test", data_file("$f")])), | |
105 | "running evp_test $f"); | |
106 | } |