From 98ced05c5695c4eff159495c7ac838707ba54f69 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Fri, 21 Sep 2007 18:00:24 +0000 Subject: [PATCH] New --rspdir option to mkfipsscr.pl to specify alternate output directory. Modify fips_aesavs and fips_desmovs to support an optional output filename with -f option. --- fips/aes/fips_aesavs.c | 33 ++++++++++++++++++++------------- fips/des/fips_desmovs.c | 33 ++++++++++++++++++++------------- fips/mkfipsscr.pl | 16 ++++++++++------ 3 files changed, 50 insertions(+), 32 deletions(-) diff --git a/fips/aes/fips_aesavs.c b/fips/aes/fips_aesavs.c index 5344aba124..0acbdd5e36 100644 --- a/fips/aes/fips_aesavs.c +++ b/fips/aes/fips_aesavs.c @@ -541,7 +541,7 @@ int do_mct(char *amode, # Fri Aug 30 04:07:22 PM ----------------------------*/ -int proc_file(char *rqfile) +int proc_file(char *rqfile, char *rspfile) { char afn[256], rfn[256]; FILE *afp = NULL, *rfp = NULL; @@ -573,17 +573,21 @@ int proc_file(char *rqfile) afn, strerror(errno)); return -1; } - strcpy(rfn,afn); - rp=strstr(rfn,"req/"); + if (!rspfile) + { + strcpy(rfn,afn); + rp=strstr(rfn,"req/"); #ifdef OPENSSL_SYS_WIN32 - if (!rp) - rp=strstr(rfn,"req\\"); + if (!rp) + rp=strstr(rfn,"req\\"); #endif - assert(rp); - memcpy(rp,"rsp",3); - rp = strstr(rfn, ".req"); - memcpy(rp, ".rsp", 4); - if ((rfp = fopen(rfn, "w")) == NULL) + assert(rp); + memcpy(rp,"rsp",3); + rp = strstr(rfn, ".req"); + memcpy(rp, ".rsp", 4); + rspfile = rfn; + } + if ((rfp = fopen(rspfile, "w")) == NULL) { printf("Cannot open file: %s, %s\n", rfn, strerror(errno)); @@ -852,7 +856,7 @@ int proc_file(char *rqfile) --------------------------------------------------*/ int main(int argc, char **argv) { - char *rqlist = "req.txt"; + char *rqlist = "req.txt", *rspfile = NULL; FILE *fp = NULL; char fn[250] = "", rfn[256] = ""; int f_opt = 0, d_opt = 1; @@ -888,7 +892,10 @@ int main(int argc, char **argv) if (d_opt) rqlist = argv[2]; else + { strcpy(fn, argv[2]); + rspfile = argv[3]; + } } if (d_opt) { /* list of files (directory) */ @@ -903,7 +910,7 @@ int main(int argc, char **argv) strcpy(rfn, fn); if (VERBOSE) printf("Processing: %s\n", rfn); - if (proc_file(rfn)) + if (proc_file(rfn, rspfile)) { printf(">>> Processing failed for: %s <<<\n", rfn); EXIT(1); @@ -915,7 +922,7 @@ int main(int argc, char **argv) { if (VERBOSE) printf("Processing: %s\n", fn); - if (proc_file(fn)) + if (proc_file(fn, rspfile)) { printf(">>> Processing failed for: %s <<<\n", fn); } diff --git a/fips/des/fips_desmovs.c b/fips/des/fips_desmovs.c index 836c4a0b09..60edc60d08 100644 --- a/fips/des/fips_desmovs.c +++ b/fips/des/fips_desmovs.c @@ -266,7 +266,7 @@ void do_mct(char *amode, } } -int proc_file(char *rqfile) +int proc_file(char *rqfile, char *rspfile) { char afn[256], rfn[256]; FILE *afp = NULL, *rfp = NULL; @@ -297,17 +297,21 @@ int proc_file(char *rqfile) afn, strerror(errno)); return -1; } - strcpy(rfn,afn); - rp=strstr(rfn,"req/"); + if (!rspfile) + { + strcpy(rfn,afn); + rp=strstr(rfn,"req/"); #ifdef OPENSSL_SYS_WIN32 - if (!rp) - rp=strstr(rfn,"req\\"); + if (!rp) + rp=strstr(rfn,"req\\"); #endif - assert(rp); - memcpy(rp,"rsp",3); - rp = strstr(rfn, ".req"); - memcpy(rp, ".rsp", 4); - if ((rfp = fopen(rfn, "w")) == NULL) + assert(rp); + memcpy(rp,"rsp",3); + rp = strstr(rfn, ".req"); + memcpy(rp, ".rsp", 4); + rspfile = rfn; + } + if ((rfp = fopen(rspfile, "w")) == NULL) { printf("Cannot open file: %s, %s\n", rfn, strerror(errno)); @@ -623,7 +627,7 @@ int proc_file(char *rqfile) --------------------------------------------------*/ int main(int argc, char **argv) { - char *rqlist = "req.txt"; + char *rqlist = "req.txt", *rspfile = NULL; FILE *fp = NULL; char fn[250] = "", rfn[256] = ""; int f_opt = 0, d_opt = 1; @@ -659,7 +663,10 @@ int main(int argc, char **argv) if (d_opt) rqlist = argv[2]; else + { strcpy(fn, argv[2]); + rspfile = argv[3]; + } } if (d_opt) { /* list of files (directory) */ @@ -673,7 +680,7 @@ int main(int argc, char **argv) strtok(fn, "\r\n"); strcpy(rfn, fn); printf("Processing: %s\n", rfn); - if (proc_file(rfn)) + if (proc_file(rfn, rspfile)) { printf(">>> Processing failed for: %s <<<\n", rfn); EXIT(1); @@ -685,7 +692,7 @@ int main(int argc, char **argv) { if (VERBOSE) printf("Processing: %s\n", fn); - if (proc_file(fn)) + if (proc_file(fn, rspfile)) { printf(">>> Processing failed for: %s <<<\n", fn); } diff --git a/fips/mkfipsscr.pl b/fips/mkfipsscr.pl index 7a240a8a83..b112499e7f 100644 --- a/fips/mkfipsscr.pl +++ b/fips/mkfipsscr.pl @@ -286,6 +286,7 @@ my $tprefix; my $shwrap_prefix; my $debug = 0; my $quiet = 0; +my $rspdir = "rsp"; foreach (@ARGV) { @@ -308,7 +309,10 @@ foreach (@ARGV) elsif (/--dir=(.*)$/) { $tvdir = $1; - # $tvdir .= "/" unless $tvdir =~ /\/$/; + } + elsif (/--rspdir=(.*)$/) + { + $rspdir = $1; } elsif (/--tprefix=(.*)$/) { @@ -433,7 +437,7 @@ sub test_dir { my ($win32, $req) = @_; my $rsp = $req; - $rsp =~ s/req$/rsp/; + $rsp =~ s/req$/$rspdir/; if ($win32) { $rsp =~ tr|/|\\|; @@ -460,17 +464,19 @@ END sub test_line { my ($win32, $req, $tprefix, $tcmd) = @_; + my $rsp = $req; + $rsp =~ s/req\/([^\/]*).req$/$rspdir\/$1.rsp/; if ($tcmd =~ /-f$/) { if ($win32) { $req =~ tr|/|\\|; - print OUT "$tprefix$tcmd \"$req\"\n"; + print OUT "$tprefix$tcmd \"$req\" \"$rsp\"\n"; } else { print OUT <