~ubuntu-branches/ubuntu/lucid/openssl/lucid-proposed

« back to all changes in this revision

Viewing changes to fips/mkfipsscr.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-06-13 18:15:46 UTC
  • mto: (11.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090613181546-vbfntai3b009dl1u
Tags: upstream-0.9.8k
ImportĀ upstreamĀ versionĀ 0.9.8k

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/local/bin/perl -w
 
2
# Quick & dirty utility to generate a script for executing the
 
3
# FIPS 140-2 CMVP algorithm tests based on the pathnames of
 
4
# input algorithm test files actually present (the unqualified
 
5
# file names are consistent but the pathnames are not).
 
6
#
 
7
 
 
8
# List of all the unqualified file names we expect.
 
9
my %fips_tests = (
 
10
 
 
11
# FIPS test definitions
 
12
 
 
13
# DSA tests
 
14
 
 
15
"PQGGen" => "fips_dssvs pqg",
 
16
"KeyPair" => "fips_dssvs keypair",
 
17
"SigGen" => "fips_dssvs siggen",
 
18
"SigVer" => "fips_dssvs sigver",
 
19
 
 
20
# SHA tests
 
21
 
 
22
"SHA1LongMsg" => "fips_shatest",
 
23
"SHA1Monte" => "fips_shatest",
 
24
"SHA1ShortMsg" => "fips_shatest",
 
25
"SHA224LongMsg" => "fips_shatest",
 
26
"SHA224Monte" => "fips_shatest",
 
27
"SHA224ShortMsg" => "fips_shatest",
 
28
"SHA256LongMsg" => "fips_shatest",
 
29
"SHA256Monte" => "fips_shatest",
 
30
"SHA256ShortMsg" => "fips_shatest",
 
31
"SHA384LongMsg" => "fips_shatest",
 
32
"SHA384Monte" => "fips_shatest",
 
33
"SHA384ShortMsg" => "fips_shatest",
 
34
"SHA512LongMsg" => "fips_shatest",
 
35
"SHA512Monte" => "fips_shatest",
 
36
"SHA512ShortMsg" => "fips_shatest",
 
37
 
 
38
# HMAC
 
39
 
 
40
"HMAC" => "fips_hmactest",
 
41
 
 
42
# RAND tests
 
43
 
 
44
"ANSI931_AES128MCT" => "fips_rngvs mct",
 
45
"ANSI931_AES192MCT" => "fips_rngvs mct",
 
46
"ANSI931_AES256MCT" => "fips_rngvs mct",
 
47
"ANSI931_AES128VST" => "fips_rngvs vst",
 
48
"ANSI931_AES192VST" => "fips_rngvs vst",
 
49
"ANSI931_AES256VST" => "fips_rngvs vst",
 
50
 
 
51
# RSA tests
 
52
 
 
53
"SigGen15" => "fips_rsastest",
 
54
"SigVer15" => "fips_rsavtest",
 
55
"SigGenPSS" => "fips_rsastest -saltlen SALT",
 
56
"SigVerPSS" => "fips_rsavtest -saltlen SALT",
 
57
"SigGenRSA" => "fips_rsastest -x931",
 
58
"SigVerRSA" => "fips_rsavtest -x931",
 
59
"KeyGenRSA" => "fips_rsagtest",
 
60
 
 
61
# AES tests
 
62
 
 
63
"CBCGFSbox128" => "fips_aesavs -f",
 
64
"CBCGFSbox192" => "fips_aesavs -f",
 
65
"CBCGFSbox256" => "fips_aesavs -f",
 
66
"CBCKeySbox128" => "fips_aesavs -f",
 
67
"CBCKeySbox192" => "fips_aesavs -f",
 
68
"CBCKeySbox256" => "fips_aesavs -f",
 
69
"CBCMCT128" => "fips_aesavs -f",
 
70
"CBCMCT192" => "fips_aesavs -f",
 
71
"CBCMCT256" => "fips_aesavs -f",
 
72
"CBCMMT128" => "fips_aesavs -f",
 
73
"CBCMMT192" => "fips_aesavs -f",
 
74
"CBCMMT256" => "fips_aesavs -f",
 
75
"CBCVarKey128" => "fips_aesavs -f",
 
76
"CBCVarKey192" => "fips_aesavs -f",
 
77
"CBCVarKey256" => "fips_aesavs -f",
 
78
"CBCVarTxt128" => "fips_aesavs -f",
 
79
"CBCVarTxt192" => "fips_aesavs -f",
 
80
"CBCVarTxt256" => "fips_aesavs -f",
 
81
"CFB128GFSbox128" => "fips_aesavs -f",
 
82
"CFB128GFSbox192" => "fips_aesavs -f",
 
83
"CFB128GFSbox256" => "fips_aesavs -f",
 
84
"CFB128KeySbox128" => "fips_aesavs -f",
 
85
"CFB128KeySbox192" => "fips_aesavs -f",
 
86
"CFB128KeySbox256" => "fips_aesavs -f",
 
87
"CFB128MCT128" => "fips_aesavs -f",
 
88
"CFB128MCT192" => "fips_aesavs -f",
 
89
"CFB128MCT256" => "fips_aesavs -f",
 
90
"CFB128MMT128" => "fips_aesavs -f",
 
91
"CFB128MMT192" => "fips_aesavs -f",
 
92
"CFB128MMT256" => "fips_aesavs -f",
 
93
"CFB128VarKey128" => "fips_aesavs -f",
 
94
"CFB128VarKey192" => "fips_aesavs -f",
 
95
"CFB128VarKey256" => "fips_aesavs -f",
 
96
"CFB128VarTxt128" => "fips_aesavs -f",
 
97
"CFB128VarTxt192" => "fips_aesavs -f",
 
98
"CFB128VarTxt256" => "fips_aesavs -f",
 
99
"CFB8GFSbox128" => "fips_aesavs -f",
 
100
"CFB8GFSbox192" => "fips_aesavs -f",
 
101
"CFB8GFSbox256" => "fips_aesavs -f",
 
102
"CFB8KeySbox128" => "fips_aesavs -f",
 
103
"CFB8KeySbox192" => "fips_aesavs -f",
 
104
"CFB8KeySbox256" => "fips_aesavs -f",
 
105
"CFB8MCT128" => "fips_aesavs -f",
 
106
"CFB8MCT192" => "fips_aesavs -f",
 
107
"CFB8MCT256" => "fips_aesavs -f",
 
108
"CFB8MMT128" => "fips_aesavs -f",
 
109
"CFB8MMT192" => "fips_aesavs -f",
 
110
"CFB8MMT256" => "fips_aesavs -f",
 
111
"CFB8VarKey128" => "fips_aesavs -f",
 
112
"CFB8VarKey192" => "fips_aesavs -f",
 
113
"CFB8VarKey256" => "fips_aesavs -f",
 
114
"CFB8VarTxt128" => "fips_aesavs -f",
 
115
"CFB8VarTxt192" => "fips_aesavs -f",
 
116
"CFB8VarTxt256" => "fips_aesavs -f",
 
117
#"CFB1GFSbox128" => "fips_aesavs -f",
 
118
#"CFB1GFSbox192" => "fips_aesavs -f",
 
119
#"CFB1GFSbox256" => "fips_aesavs -f",
 
120
#"CFB1KeySbox128" => "fips_aesavs -f",
 
121
#"CFB1KeySbox192" => "fips_aesavs -f",
 
122
#"CFB1KeySbox256" => "fips_aesavs -f",
 
123
#"CFB1MCT128" => "fips_aesavs -f",
 
124
#"CFB1MCT192" => "fips_aesavs -f",
 
125
#"CFB1MCT256" => "fips_aesavs -f",
 
126
#"CFB1MMT128" => "fips_aesavs -f",
 
127
#"CFB1MMT192" => "fips_aesavs -f",
 
128
#"CFB1MMT256" => "fips_aesavs -f",
 
129
#"CFB1VarKey128" => "fips_aesavs -f",
 
130
#"CFB1VarKey192" => "fips_aesavs -f",
 
131
#"CFB1VarKey256" => "fips_aesavs -f",
 
132
#"CFB1VarTxt128" => "fips_aesavs -f",
 
133
#"CFB1VarTxt192" => "fips_aesavs -f",
 
134
#"CFB1VarTxt256" => "fips_aesavs -f",
 
135
"ECBGFSbox128" => "fips_aesavs -f",
 
136
"ECBGFSbox192" => "fips_aesavs -f",
 
137
"ECBGFSbox256" => "fips_aesavs -f",
 
138
"ECBKeySbox128" => "fips_aesavs -f",
 
139
"ECBKeySbox192" => "fips_aesavs -f",
 
140
"ECBKeySbox256" => "fips_aesavs -f",
 
141
"ECBMCT128" => "fips_aesavs -f",
 
142
"ECBMCT192" => "fips_aesavs -f",
 
143
"ECBMCT256" => "fips_aesavs -f",
 
144
"ECBMMT128" => "fips_aesavs -f",
 
145
"ECBMMT192" => "fips_aesavs -f",
 
146
"ECBMMT256" => "fips_aesavs -f",
 
147
"ECBVarKey128" => "fips_aesavs -f",
 
148
"ECBVarKey192" => "fips_aesavs -f",
 
149
"ECBVarKey256" => "fips_aesavs -f",
 
150
"ECBVarTxt128" => "fips_aesavs -f",
 
151
"ECBVarTxt192" => "fips_aesavs -f",
 
152
"ECBVarTxt256" => "fips_aesavs -f",
 
153
"OFBGFSbox128" => "fips_aesavs -f",
 
154
"OFBGFSbox192" => "fips_aesavs -f",
 
155
"OFBGFSbox256" => "fips_aesavs -f",
 
156
"OFBKeySbox128" => "fips_aesavs -f",
 
157
"OFBKeySbox192" => "fips_aesavs -f",
 
158
"OFBKeySbox256" => "fips_aesavs -f",
 
159
"OFBMCT128" => "fips_aesavs -f",
 
160
"OFBMCT192" => "fips_aesavs -f",
 
161
"OFBMCT256" => "fips_aesavs -f",
 
162
"OFBMMT128" => "fips_aesavs -f",
 
163
"OFBMMT192" => "fips_aesavs -f",
 
164
"OFBMMT256" => "fips_aesavs -f",
 
165
"OFBVarKey128" => "fips_aesavs -f",
 
166
"OFBVarKey192" => "fips_aesavs -f",
 
167
"OFBVarKey256" => "fips_aesavs -f",
 
168
"OFBVarTxt128" => "fips_aesavs -f",
 
169
"OFBVarTxt192" => "fips_aesavs -f",
 
170
"OFBVarTxt256" => "fips_aesavs -f",
 
171
 
 
172
# Triple DES tests
 
173
 
 
174
"TCBCinvperm" => "fips_desmovs -f",
 
175
"TCBCMMT1" => "fips_desmovs -f",
 
176
"TCBCMMT2" => "fips_desmovs -f",
 
177
"TCBCMMT3" => "fips_desmovs -f",
 
178
"TCBCMonte1" => "fips_desmovs -f",
 
179
"TCBCMonte2" => "fips_desmovs -f",
 
180
"TCBCMonte3" => "fips_desmovs -f",
 
181
"TCBCpermop" => "fips_desmovs -f",
 
182
"TCBCsubtab" => "fips_desmovs -f",
 
183
"TCBCvarkey" => "fips_desmovs -f",
 
184
"TCBCvartext" => "fips_desmovs -f",
 
185
"TCFB64invperm" => "fips_desmovs -f",
 
186
"TCFB64MMT1" => "fips_desmovs -f",
 
187
"TCFB64MMT2" => "fips_desmovs -f",
 
188
"TCFB64MMT3" => "fips_desmovs -f",
 
189
"TCFB64Monte1" => "fips_desmovs -f",
 
190
"TCFB64Monte2" => "fips_desmovs -f",
 
191
"TCFB64Monte3" => "fips_desmovs -f",
 
192
"TCFB64permop" => "fips_desmovs -f",
 
193
"TCFB64subtab" => "fips_desmovs -f",
 
194
"TCFB64varkey" => "fips_desmovs -f",
 
195
"TCFB64vartext" => "fips_desmovs -f",
 
196
"TCFB8invperm" => "fips_desmovs -f",
 
197
"TCFB8MMT1" => "fips_desmovs -f",
 
198
"TCFB8MMT2" => "fips_desmovs -f",
 
199
"TCFB8MMT3" => "fips_desmovs -f",
 
200
"TCFB8Monte1" => "fips_desmovs -f",
 
201
"TCFB8Monte2" => "fips_desmovs -f",
 
202
"TCFB8Monte3" => "fips_desmovs -f",
 
203
"TCFB8permop" => "fips_desmovs -f",
 
204
"TCFB8subtab" => "fips_desmovs -f",
 
205
"TCFB8varkey" => "fips_desmovs -f",
 
206
"TCFB8vartext" => "fips_desmovs -f",
 
207
"TECBinvperm" => "fips_desmovs -f",
 
208
"TECBMMT1" => "fips_desmovs -f",
 
209
"TECBMMT2" => "fips_desmovs -f",
 
210
"TECBMMT3" => "fips_desmovs -f",
 
211
"TECBMonte1" => "fips_desmovs -f",
 
212
"TECBMonte2" => "fips_desmovs -f",
 
213
"TECBMonte3" => "fips_desmovs -f",
 
214
"TECBpermop" => "fips_desmovs -f",
 
215
"TECBsubtab" => "fips_desmovs -f",
 
216
"TECBvarkey" => "fips_desmovs -f",
 
217
"TECBvartext" => "fips_desmovs -f",
 
218
"TOFBinvperm" => "fips_desmovs -f",
 
219
"TOFBMMT1" => "fips_desmovs -f",
 
220
"TOFBMMT2" => "fips_desmovs -f",
 
221
"TOFBMMT3" => "fips_desmovs -f",
 
222
"TOFBMonte1" => "fips_desmovs -f",
 
223
"TOFBMonte2" => "fips_desmovs -f",
 
224
"TOFBMonte3" => "fips_desmovs -f",
 
225
"TOFBpermop" => "fips_desmovs -f",
 
226
"TOFBsubtab" => "fips_desmovs -f",
 
227
"TOFBvarkey" => "fips_desmovs -f",
 
228
"TOFBvartext" => "fips_desmovs -f",
 
229
"TCBCinvperm" => "fips_desmovs -f",
 
230
"TCBCMMT1" => "fips_desmovs -f",
 
231
"TCBCMMT2" => "fips_desmovs -f",
 
232
"TCBCMMT3" => "fips_desmovs -f",
 
233
"TCBCMonte1" => "fips_desmovs -f",
 
234
"TCBCMonte2" => "fips_desmovs -f",
 
235
"TCBCMonte3" => "fips_desmovs -f",
 
236
"TCBCpermop" => "fips_desmovs -f",
 
237
"TCBCsubtab" => "fips_desmovs -f",
 
238
"TCBCvarkey" => "fips_desmovs -f",
 
239
"TCBCvartext" => "fips_desmovs -f",
 
240
"TCFB64invperm" => "fips_desmovs -f",
 
241
"TCFB64MMT1" => "fips_desmovs -f",
 
242
"TCFB64MMT2" => "fips_desmovs -f",
 
243
"TCFB64MMT3" => "fips_desmovs -f",
 
244
"TCFB64Monte1" => "fips_desmovs -f",
 
245
"TCFB64Monte2" => "fips_desmovs -f",
 
246
"TCFB64Monte3" => "fips_desmovs -f",
 
247
"TCFB64permop" => "fips_desmovs -f",
 
248
"TCFB64subtab" => "fips_desmovs -f",
 
249
"TCFB64varkey" => "fips_desmovs -f",
 
250
"TCFB64vartext" => "fips_desmovs -f",
 
251
"TCFB8invperm" => "fips_desmovs -f",
 
252
"TCFB8MMT1" => "fips_desmovs -f",
 
253
"TCFB8MMT2" => "fips_desmovs -f",
 
254
"TCFB8MMT3" => "fips_desmovs -f",
 
255
"TCFB8Monte1" => "fips_desmovs -f",
 
256
"TCFB8Monte2" => "fips_desmovs -f",
 
257
"TCFB8Monte3" => "fips_desmovs -f",
 
258
"TCFB8permop" => "fips_desmovs -f",
 
259
"TCFB8subtab" => "fips_desmovs -f",
 
260
"TCFB8varkey" => "fips_desmovs -f",
 
261
"TCFB8vartext" => "fips_desmovs -f",
 
262
"TECBinvperm" => "fips_desmovs -f",
 
263
"TECBMMT1" => "fips_desmovs -f",
 
264
"TECBMMT2" => "fips_desmovs -f",
 
265
"TECBMMT3" => "fips_desmovs -f",
 
266
"TECBMonte1" => "fips_desmovs -f",
 
267
"TECBMonte2" => "fips_desmovs -f",
 
268
"TECBMonte3" => "fips_desmovs -f",
 
269
"TECBpermop" => "fips_desmovs -f",
 
270
"TECBsubtab" => "fips_desmovs -f",
 
271
"TECBvarkey" => "fips_desmovs -f",
 
272
"TECBvartext" => "fips_desmovs -f",
 
273
"TOFBinvperm" => "fips_desmovs -f",
 
274
"TOFBMMT1" => "fips_desmovs -f",
 
275
"TOFBMMT2" => "fips_desmovs -f",
 
276
"TOFBMMT3" => "fips_desmovs -f",
 
277
"TOFBMonte1" => "fips_desmovs -f",
 
278
"TOFBMonte2" => "fips_desmovs -f",
 
279
"TOFBMonte3" => "fips_desmovs -f",
 
280
"TOFBpermop" => "fips_desmovs -f",
 
281
"TOFBsubtab" => "fips_desmovs -f",
 
282
"TOFBvarkey" => "fips_desmovs -f",
 
283
"TOFBvartext" => "fips_desmovs -f"
 
284
 
 
285
);
 
286
my %salt_names = (
 
287
"SigVerPSS (salt 0)" => "SigVerPSS",
 
288
"SigVerPSS (salt 62)" => "SigVerPSS",
 
289
"SigGenPSS (salt 0)" => "SigGenPSS",
 
290
"SigGenPSS (salt 62)" => "SigGenPSS",
 
291
);
 
292
 
 
293
 
 
294
my $win32 = $^O =~ m/mswin/i;
 
295
my $onedir = 0;
 
296
my $filter = "";
 
297
my $tvdir;
 
298
my $tprefix;
 
299
my $shwrap_prefix;
 
300
my $debug = 0;
 
301
my $quiet = 0;
 
302
my $rspdir = "rsp";
 
303
my $rspignore = 0;
 
304
my @bogus = ();                 # list of unmatched *.rsp files
 
305
my $bufout = '';
 
306
my %_programs = ();             # list of external programs to check
 
307
 
 
308
foreach (@ARGV)
 
309
        {
 
310
        if ($_ eq "--win32")
 
311
                {
 
312
                $win32 = 1;
 
313
                }
 
314
        elsif ($_ eq "--onedir")
 
315
                {
 
316
                $onedir = 1;
 
317
                }
 
318
        elsif ($_ eq "--debug")
 
319
                {
 
320
                $debug = 1;
 
321
                }
 
322
        elsif ($_ eq "--quiet")
 
323
                {
 
324
                $quiet = 1;
 
325
                }
 
326
        elsif (/--dir=(.*)$/)
 
327
                {
 
328
                $tvdir = $1;
 
329
                }
 
330
        elsif (/--rspdir=(.*)$/)
 
331
                {
 
332
                $rspdir = $1;
 
333
                }
 
334
        elsif (/--rspignore$/)
 
335
                {
 
336
                $rspignore = 1;
 
337
                }
 
338
        elsif (/--tprefix=(.*)$/)
 
339
                {
 
340
                $tprefix = $1;
 
341
                }
 
342
        elsif (/--shwrap_prefix=(.*)$/)
 
343
                {
 
344
                $shwrap_prefix = $1;
 
345
                }
 
346
        elsif (/--filter=(.*)$/)
 
347
                {
 
348
                $filter = $1;
 
349
                }
 
350
        elsif (/--outfile=(.*)$/)
 
351
                {
 
352
                $outfile = $1;
 
353
                }
 
354
        else
 
355
                {
 
356
                &Help();
 
357
                exit(1);
 
358
                }
 
359
        }
 
360
 
 
361
$tvdir = "." unless defined $tvdir;
 
362
 
 
363
if ($win32)
 
364
        {
 
365
        if (!defined $tprefix)
 
366
                {
 
367
                if ($onedir)
 
368
                        {
 
369
                        $tprefix = ".\\";
 
370
                        }
 
371
                else
 
372
                        {
 
373
                        $tprefix = "..\\out32dll\\";
 
374
                        }
 
375
                }
 
376
 
 
377
        $bufinit .= <<END;
 
378
\@echo off
 
379
rem Test vector run script
 
380
rem Auto generated by mkfipsscr.pl script
 
381
rem Do not edit
 
382
 
 
383
END
 
384
 
 
385
        }
 
386
else
 
387
        {
 
388
        if ($onedir)
 
389
                {
 
390
                $tprefix = "./" unless defined $tprefix;
 
391
                $shwrap_prefix = "./" unless defined $shwrap_prefix;
 
392
                }
 
393
        else
 
394
                {
 
395
                $tprefix = "../test/" unless defined $tprefix;
 
396
                $shwrap_prefix = "../util/" unless defined $shwrap_prefix;
 
397
                }
 
398
 
 
399
        $bufinit .= <<END;
 
400
#!/bin/sh
 
401
 
 
402
# Test vector run script
 
403
# Auto generated by mkfipsscr.pl script
 
404
# Do not edit
 
405
 
 
406
END
 
407
 
 
408
        }
 
409
my %fips_found;
 
410
foreach (keys %fips_tests)
 
411
        {
 
412
        $fips_found{$_} = 0;
 
413
        }
 
414
my %saltPSS;
 
415
for (keys %salt_names)
 
416
        {
 
417
        $salt_found{$_} = 0;
 
418
        }
 
419
 
 
420
recurse_test($win32, $tprefix, $filter, $tvdir);
 
421
 
 
422
while (($key, $value) = each %salt_found)
 
423
        {
 
424
        &countentry($key, $value);
 
425
        delete $fips_found{$salt_names{$key}};
 
426
        }
 
427
while (($key, $value) = each %fips_found)
 
428
        {
 
429
        &countentry($key, $value);
 
430
        }
 
431
 
 
432
# If no fatal errors write out the script file
 
433
        $outfile = "fipstests.sh" unless defined $outfile;
 
434
        open(OUT, ">$outfile") || die "Error opening $outfile: $!";
 
435
        print OUT $bufinit;
 
436
        if (!$rspignore && @bogus)
 
437
                {
 
438
                print STDERR "ERROR: please remove bogus *.rsp files\n";
 
439
                print OUT <<EOF;
 
440
echo $outfile generation failed due to presence of bogus *.rsp files
 
441
EOF
 
442
                }
 
443
        else
 
444
                {
 
445
                print OUT $bufout;
 
446
                }
 
447
        close OUT;
 
448
 
 
449
# Check for external programs
 
450
        for (keys %_programs)
 
451
                {
 
452
                s/ .*$//;
 
453
                -x $_ || print STDERR "WARNING: program $_ not found\n";
 
454
                }
 
455
 
 
456
#--------------------------------
 
457
sub Help {
 
458
(my $cmd) = ($0 =~ m#([^/]+)$#);
 
459
        print <<EOF;
 
460
$cmd: generate script for CMVP algorithm tests
 
461
        --debug                     Enable debug output
 
462
        --dir=<dirname>             Optional root for *.req file search
 
463
        --filter=<regexp>
 
464
        --onedir <dirname>          Assume all components in current directory
 
465
        --outfile=<filename>        Optional name of output script, default fipstests.{sh|bat}
 
466
        --rspdir=<dirname>          Name of subdirectories containing *.rsp files, default "resp"
 
467
        --rspignore                 Ignore any bogus *.rsp files
 
468
        --shwrap_prefix=<prefix>
 
469
        --tprefix=<prefix>
 
470
        --quiet                     Shhh....
 
471
        --win32                     Generate script for Win32 environment
 
472
EOF
 
473
}
 
474
 
 
475
#--------------------------------
 
476
sub countentry {
 
477
        my ($key,$value) = @_;
 
478
        if ($value == 0)
 
479
                {
 
480
                print STDERR "WARNING: test file $key not found\n" unless $quiet;
 
481
                }
 
482
        elsif ($value > 1)
 
483
                {
 
484
                print STDERR "WARNING: test file $key found $value times\n" unless $quiet;
 
485
                }
 
486
        else 
 
487
                {
 
488
                print STDERR "Found test file $key\n" if $debug;
 
489
                }
 
490
        }
 
491
 
 
492
#--------------------------------
 
493
sub recurse_test
 
494
        {
 
495
        my ($win32, $tprefix, $filter, $dir) = @_;
 
496
        my $dirh;
 
497
        opendir($dirh, $dir);
 
498
        while ($_ = readdir($dirh))
 
499
                {
 
500
                next if ($_ eq "." || $_ eq "..");
 
501
                $_ = "$dir/$_";
 
502
                if (-f "$_")
 
503
                        {
 
504
                        if (/\/([^\/]*)\.rsp$/)
 
505
                                {
 
506
                                if (exists $fips_tests{$1})
 
507
                                        {
 
508
                                        $debug && print "DEBUG: $1 found, will be overwritten\n";
 
509
                                        }
 
510
                                else
 
511
                                        {
 
512
                                        print STDERR "ERROR: bogus file $_\n";
 
513
                                        push @bogus, $_;
 
514
                                        }
 
515
                                }
 
516
                        next unless /$filter.*\.req$/i;
 
517
                        if (/\/([^\/]*)\.req$/ && exists $fips_tests{$1})
 
518
                                {
 
519
                                $fips_found{$1}++;
 
520
                                test_line($win32, $_, $tprefix, $1);
 
521
                                }
 
522
                        elsif (! /SHAmix\.req$/)
 
523
                                {
 
524
                                print STDERR "WARNING: unrecognized filename $_\n";
 
525
                                }
 
526
                        }
 
527
                elsif (-d "$_")
 
528
                        {
 
529
                        if (/$filter.*req$/i)
 
530
                                {
 
531
                                test_dir($win32, $_);
 
532
                                }
 
533
                        recurse_test($win32, $tprefix, $filter, $_);
 
534
                        }
 
535
                }
 
536
        closedir($dirh);
 
537
        }
 
538
 
 
539
#--------------------------------
 
540
sub test_dir
 
541
        {
 
542
        my ($win32, $req) = @_;
 
543
        my $rsp = $req;
 
544
        $rsp =~ s/req$/$rspdir/;
 
545
        if ($win32)
 
546
                {
 
547
                $rsp =~ tr|/|\\|;
 
548
                $req =~ tr|/|\\|;
 
549
                $bufout .= <<END;
 
550
 
 
551
echo Running tests in $req
 
552
if exist "$rsp" rd /s /q "$rsp"
 
553
md "$rsp"
 
554
END
 
555
                }
 
556
        else
 
557
                {
 
558
                $bufout .= <<END;
 
559
 
 
560
echo Running tests in "$req"
 
561
rm -rf "$rsp"
 
562
mkdir "$rsp"
 
563
 
 
564
END
 
565
                }
 
566
        }
 
567
 
 
568
#--------------------------------
 
569
sub test_line
 
570
        {
 
571
        my ($win32, $req, $tprefix, $tnam) = @_;
 
572
        my $rsp = $req;
 
573
        my $tcmd = $fips_tests{$tnam};
 
574
        $rsp =~ s/req\/([^\/]*).req$/$rspdir\/$1.rsp/;
 
575
        if ($tcmd =~ /-f$/)
 
576
                {
 
577
                if ($win32)
 
578
                        {
 
579
                        $req =~ tr|/|\\|;
 
580
                        $rsp =~ tr|/|\\|;
 
581
                        $bufout .= "$tprefix$tcmd \"$req\" \"$rsp\"\n";
 
582
                        $_programs{"$tprefix$tcmd.exe"} = 1;
 
583
                        }
 
584
                else
 
585
                        {
 
586
                        $bufout .= <<END;
 
587
${shwrap_prefix}shlib_wrap.sh $tprefix$tcmd "$req" "$rsp" || { echo "$req failure" ; exit 1 
 
588
}
 
589
END
 
590
                        $_programs{"${shwrap_prefix}shlib_wrap.sh"} = 1;
 
591
                        $_programs{"$tprefix$tcmd"} = 1;
 
592
                        }
 
593
                return;
 
594
                }
 
595
        if ($tcmd =~ /SALT$/)
 
596
                {
 
597
                open (IN, $req) || die "Can't Open File $req";
 
598
                my $saltlen;
 
599
                while (<IN>)
 
600
                        {
 
601
                        if (/^\s*#\s*salt\s+len:\s+(\d+)\s*$/i)
 
602
                                {
 
603
                                my $sl = $1;
 
604
                                print STDERR "$req salt length $sl\n" if $debug;
 
605
                                $tcmd =~ s/SALT$/$sl/;
 
606
                                $salt_found{"$tnam (salt $sl)"}++;
 
607
                                last;
 
608
                                }
 
609
                        }
 
610
                close IN;
 
611
                if ($tcmd =~ /SALT$/)
 
612
                        {
 
613
                        die "Can't detect salt length for $req";
 
614
                        }
 
615
                }
 
616
                
 
617
        if ($win32)
 
618
                {
 
619
                $req =~ tr|/|\\|;
 
620
                $rsp =~ tr|/|\\|;
 
621
                $bufout .= "$tprefix$tcmd < \"$req\" > \"$rsp\"\n";
 
622
                $_programs{"$tprefix$tcmd.exe"} = 1;
 
623
                }
 
624
        else
 
625
                {
 
626
                $bufout .= <<END;
 
627
${shwrap_prefix}shlib_wrap.sh $tprefix$tcmd < "$req" > "$rsp" || { echo "$req failure" ; exit 1; }
 
628
END
 
629
                $_programs{"$tprefix$tcmd"} = 1;
 
630
                }
 
631
        }
 
632