summaryrefslogtreecommitdiffstats
path: root/fips/rand
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2011-03-08 13:27:29 +0000
committerDr. Stephen Henson <steve@openssl.org>2011-03-08 13:27:29 +0000
commit12b77cbec33a958f000f0eb424d3bd7d5be8f554 (patch)
tree23f4e7b7bd08c43b049cb7fe278a05e7ace52e63 /fips/rand
parente45c6c4e2537434f087793e5c51a5cb70af9d82e (diff)
Remove need for redirection on RNG and DSS algorithm test programs: some
platforms don't support it.
Diffstat (limited to 'fips/rand')
-rw-r--r--fips/rand/fips_rngvs.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/fips/rand/fips_rngvs.c b/fips/rand/fips_rngvs.c
index be03ae3770..786f5420b4 100644
--- a/fips/rand/fips_rngvs.c
+++ b/fips/rand/fips_rngvs.c
@@ -33,7 +33,7 @@ int main(int argc, char **argv)
#include "fips_utl.h"
-static void vst()
+static void vst(FILE *in, FILE *out)
{
unsigned char *key = NULL;
unsigned char *v = NULL;
@@ -46,9 +46,9 @@ static void vst()
keylen = 0;
- while(fgets(buf,sizeof buf,stdin) != NULL)
+ while(fgets(buf,sizeof buf,in) != NULL)
{
- fputs(buf,stdout);
+ fputs(buf,out);
if(!strncmp(buf,"[AES 128-Key]", 13))
keylen = 16;
else if(!strncmp(buf,"[AES 192-Key]", 13))
@@ -99,7 +99,7 @@ static void vst()
return;
}
- pv("R",ret,16);
+ OutputValue("R", ret, 16, out, 0);
OPENSSL_free(key);
key = NULL;
OPENSSL_free(dt);
@@ -110,7 +110,7 @@ static void vst()
}
}
-static void mct()
+static void mct(FILE *in, FILE *out)
{
unsigned char *key = NULL;
unsigned char *v = NULL;
@@ -124,9 +124,9 @@ static void mct()
keylen = 0;
- while(fgets(buf,sizeof buf,stdin) != NULL)
+ while(fgets(buf,sizeof buf,in) != NULL)
{
- fputs(buf,stdout);
+ fputs(buf,out);
if(!strncmp(buf,"[AES 128-Key]", 13))
keylen = 16;
else if(!strncmp(buf,"[AES 192-Key]", 13))
@@ -187,7 +187,7 @@ static void mct()
}
}
- pv("R",ret,16);
+ OutputValue("R", ret, 16, out, 0);
OPENSSL_free(key);
key = NULL;
OPENSSL_free(dt);
@@ -200,7 +200,28 @@ static void mct()
int main(int argc,char **argv)
{
- if(argc != 2)
+ FILE *in, *out;
+ if (argc == 4)
+ {
+ in = fopen(argv[2], "r");
+ if (!in)
+ {
+ fprintf(stderr, "Error opening input file\n");
+ exit(1);
+ }
+ out = fopen(argv[3], "w");
+ if (!out)
+ {
+ fprintf(stderr, "Error opening output file\n");
+ exit(1);
+ }
+ }
+ else if (argc == 2)
+ {
+ in = stdin;
+ out = stdout;
+ }
+ else
{
fprintf(stderr,"%s [mct|vst]\n",argv[0]);
exit(1);
@@ -215,15 +236,21 @@ int main(int argc,char **argv)
exit(1);
}
if(!strcmp(argv[1],"mct"))
- mct();
+ mct(in, out);
else if(!strcmp(argv[1],"vst"))
- vst();
+ vst(in, out);
else
{
fprintf(stderr,"Don't know how to %s.\n",argv[1]);
exit(1);
}
+ if (argc == 4)
+ {
+ fclose(in);
+ fclose(out);
+ }
+
return 0;
}
#endif