Remove s = s * P deferral.
[openssl.git] / fips / mkfipsscr.pl
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 $shwrap;
301 my $rmcmd = "rm -rf";
302 my $mkcmd = "mkdir";
303 my $debug = 0;
304 my $quiet = 0;
305 my $rspdir = "rsp";
306 my $rspignore = 0;
307 my @bogus = ();                 # list of unmatched *.rsp files
308 my $bufout = '';
309 my $bufdir = '';
310 my %_programs = ();             # list of external programs to check
311
312 foreach (@ARGV)
313         {
314         if ($_ eq "--win32")
315                 {
316                 $win32 = 1;
317                 }
318         elsif ($_ eq "--onedir")
319                 {
320                 $onedir = 1;
321                 }
322         elsif ($_ eq "--debug")
323                 {
324                 $debug = 1;
325                 }
326         elsif ($_ eq "--quiet")
327                 {
328                 $quiet = 1;
329                 }
330         elsif (/--dir=(.*)$/)
331                 {
332                 $tvdir = $1;
333                 }
334         elsif (/--rspdir=(.*)$/)
335                 {
336                 $rspdir = $1;
337                 }
338         elsif (/--noshwrap$/)
339                 {
340                 $shwrap = "";
341                 }
342         elsif (/--rspignore$/)
343                 {
344                 $rspignore = 1;
345                 }
346         elsif (/--tprefix=(.*)$/)
347                 {
348                 $tprefix = $1;
349                 }
350         elsif (/--shwrap_prefix=(.*)$/)
351                 {
352                 $shwrap_prefix = $1;
353                 }
354         elsif (/--filter=(.*)$/)
355                 {
356                 $filter = $1;
357                 }
358         elsif (/--mkdir=(.*)$/)
359                 {
360                 $mkcmd = $1;
361                 }
362         elsif (/--rm=(.*)$/)
363                 {
364                 $rmcmd = $1;
365                 }
366         elsif (/--outfile=(.*)$/)
367                 {
368                 $outfile = $1;
369                 }
370         else
371                 {
372                 &Help();
373                 exit(1);
374                 }
375         }
376
377 $tvdir = "." unless defined $tvdir;
378
379 if ($win32)
380         {
381         if (!defined $tprefix)
382                 {
383                 if ($onedir)
384                         {
385                         $tprefix = ".\\";
386                         }
387                 else
388                         {
389                         $tprefix = "..\\out32dll\\";
390                         }
391                 }
392
393         $bufinit .= <<END;
394 \@echo off
395 rem Test vector run script
396 rem Auto generated by mkfipsscr.pl script
397 rem Do not edit
398
399 END
400
401         }
402 else
403         {
404         if ($onedir)
405                 {
406                 $tprefix = "./" unless defined $tprefix;
407                 $shwrap_prefix = "./" unless defined $shwrap_prefix;
408                 }
409         else
410                 {
411                 $tprefix = "../test/" unless defined $tprefix;
412                 $shwrap_prefix = "../util/" unless defined $shwrap_prefix;
413                 }
414
415         $shwrap = "${shwrap_prefix}shlib_wrap.sh " unless defined $shwrap;
416
417         $bufinit .= <<END;
418 #!/bin/sh
419
420 # Test vector run script
421 # Auto generated by mkfipsscr.pl script
422 # Do not edit
423
424 RM="$rmcmd"
425 MKDIR="$mkcmd"
426 TPREFIX=$tprefix
427 END
428
429         }
430 my %fips_found;
431 foreach (keys %fips_tests)
432         {
433         $fips_found{$_} = 0;
434         }
435 my %saltPSS;
436 for (keys %salt_names)
437         {
438         $salt_found{$_} = 0;
439         }
440
441 recurse_test($win32, $tprefix, $filter, $tvdir);
442
443 while (($key, $value) = each %salt_found)
444         {
445         &countentry($key, $value);
446         delete $fips_found{$salt_names{$key}};
447         }
448 while (($key, $value) = each %fips_found)
449         {
450         &countentry($key, $value);
451         }
452
453 # If no fatal errors write out the script file
454         $outfile = "fipstests.sh" unless defined $outfile;
455         open(OUT, ">$outfile") || die "Error opening $outfile: $!";
456         print OUT $bufinit;
457         if (!$rspignore && @bogus)
458                 {
459                 print STDERR "ERROR: please remove bogus *.rsp files\n";
460                 print OUT <<EOF;
461 echo $outfile generation failed due to presence of bogus *.rsp files
462 EOF
463                 }
464         else
465                 {
466                 print OUT $bufout;
467                 }
468         close OUT;
469
470 # Check for external programs
471         for (keys %_programs)
472                 {
473                 s/ .*$//;
474                 -x $_ || print STDERR "WARNING: program $_ not found\n";
475                 }
476
477 #--------------------------------
478 sub Help {
479 (my $cmd) = ($0 =~ m#([^/]+)$#);
480         print <<EOF;
481 $cmd: generate script for CMVP algorithm tests
482         --debug                     Enable debug output
483         --dir=<dirname>             Optional root for *.req file search
484         --filter=<regexp>
485         --onedir <dirname>          Assume all components in current directory
486         --outfile=<filename>        Optional name of output script, default fipstests.{sh|bat}
487         --rspdir=<dirname>          Name of subdirectories containing *.rsp files, default "resp"
488         --rspignore                 Ignore any bogus *.rsp files
489         --shwrap_prefix=<prefix>
490         --tprefix=<prefix>
491         --quiet                     Shhh....
492         --win32                     Generate script for Win32 environment
493 EOF
494 }
495
496 #--------------------------------
497 sub countentry {
498         my ($key,$value) = @_;
499         if ($value == 0)
500                 {
501                 print STDERR "WARNING: test file $key not found\n" unless $quiet;
502                 }
503         elsif ($value > 1)
504                 {
505                 print STDERR "WARNING: test file $key found $value times\n" unless $quiet;
506                 }
507         else 
508                 {
509                 print STDERR "Found test file $key\n" if $debug;
510                 }
511         }
512
513 #--------------------------------
514 sub recurse_test
515         {
516         my ($win32, $tprefix, $filter, $dir) = @_;
517         my $dirh;
518         opendir($dirh, $dir);
519         while ($_ = readdir($dirh))
520                 {
521                 next if ($_ eq "." || $_ eq "..");
522                 $_ = "$dir/$_";
523                 if (-f "$_")
524                         {
525                         if (/\/([^\/]*)\.rsp$/)
526                                 {
527                                 if (exists $fips_tests{$1})
528                                         {
529                                         $debug && print "DEBUG: $1 found, will be overwritten\n";
530                                         }
531                                 else
532                                         {
533                                         print STDERR "ERROR: bogus file $_\n";
534                                         push @bogus, $_;
535                                         }
536                                 }
537                         next unless /$filter.*\.req$/i;
538                         if (/\/([^\/]*)\.req$/ && exists $fips_tests{$1})
539                                 {
540                                 $fips_found{$1}++;
541                                 test_line($win32, $_, $tprefix, $1);
542                                 }
543                         elsif (! /SHAmix\.req$/)
544                                 {
545                                 print STDERR "WARNING: unrecognized filename $_\n";
546                                 }
547                         }
548                 elsif (-d "$_")
549                         {
550                         if (/$filter.*req$/i)
551                                 {
552                                 test_dir($win32, $_);
553                                 }
554                         recurse_test($win32, $tprefix, $filter, $_);
555                         }
556                 }
557         closedir($dirh);
558         }
559
560 #--------------------------------
561 sub test_dir
562         {
563         my ($win32, $req) = @_;
564         my $rsp = $req;
565         $rsp =~ s/req$/$rspdir/;
566         if ($win32)
567                 {
568                 $rsp =~ tr|/|\\|;
569                 $req =~ tr|/|\\|;
570                 $bufdir = <<END;
571
572 echo Running tests in $req
573 if exist "$rsp" rd /s /q "$rsp"
574 md "$rsp"
575 END
576                 }
577         else
578                 {
579                 $bufdir = <<END;
580
581 echo Running tests in "$req"
582 \$RM "$rsp"
583 \$MKDIR "$rsp"
584
585 END
586                 }
587         }
588
589 #--------------------------------
590 sub test_line
591         {
592         my ($win32, $req, $tprefix, $tnam) = @_;
593         my $rsp = $req;
594         my $tcmd = $fips_tests{$tnam};
595
596         $bufout .= $bufdir;
597         $bufdir = "";
598                 
599         $rsp =~ s/req\/([^\/]*).req$/$rspdir\/$1.rsp/;
600         if ($tcmd =~ /-f$/)
601                 {
602                 if ($win32)
603                         {
604                         $req =~ tr|/|\\|;
605                         $rsp =~ tr|/|\\|;
606                         $bufout .= "$tprefix$tcmd \"$req\" \"$rsp\"\n";
607                         $_programs{"$tprefix$tcmd.exe"} = 1;
608                         }
609                 else
610                         {
611                         $bufout .= <<END;
612 ${shwrap}\${TPREFIX}$tcmd "$req" "$rsp" || { echo "$req failure" ; exit 1 
613 }
614 END
615                         $_programs{"${shwrap_prefix}shlib_wrap.sh"} = 1;
616                         $_programs{"$tprefix$tcmd"} = 1;
617                         }
618                 return;
619                 }
620         if ($tcmd =~ /SALT$/)
621                 {
622                 open (IN, $req) || die "Can't Open File $req";
623                 my $saltlen;
624                 while (<IN>)
625                         {
626                         if (/^\s*#\s*salt\s+len:\s+(\d+)\s*$/i)
627                                 {
628                                 my $sl = $1;
629                                 print STDERR "$req salt length $sl\n" if $debug;
630                                 $tcmd =~ s/SALT$/$sl/;
631                                 $salt_found{"$tnam (salt $sl)"}++;
632                                 last;
633                                 }
634                         }
635                 close IN;
636                 if ($tcmd =~ /SALT$/)
637                         {
638                         die "Can't detect salt length for $req";
639                         }
640                 }
641                 
642         if ($win32)
643                 {
644                 $req =~ tr|/|\\|;
645                 $rsp =~ tr|/|\\|;
646                 $bufout .= "$tprefix$tcmd < \"$req\" > \"$rsp\"\n";
647                 $_programs{"$tprefix$tcmd.exe"} = 1;
648                 }
649         else
650                 {
651                 $bufout .= <<END;
652 ${shwrap}\${TPREFIX}$tcmd < "$req" > "$rsp" || { echo "$req failure" ; exit 1; }
653 END
654                 $_programs{"$tprefix$tcmd"} = 1;
655                 }
656         }
657