2 * Crude test driver for processing the VST and MCT testvector files
3 * generated by the CMVP RNGVS product.
5 * Note the input files are assumed to have a _very_ specific format
6 * as described in the NIST document "The Random Number Generator
7 * Validation System (RNGVS)", May 25, 2004.
10 #include <openssl/opensslconf.h>
15 int main(int argc, char **argv)
17 printf("No FIPS RNG support\n");
22 #include <openssl/bn.h>
23 #include <openssl/dsa.h>
24 #include <openssl/fips.h>
25 #include <openssl/err.h>
26 #include <openssl/rand.h>
27 #include <openssl/fips_rand.h>
28 #include <openssl/x509v3.h>
36 unsigned char *key = NULL;
37 unsigned char *v = NULL;
38 unsigned char *dt = NULL;
39 unsigned char ret[16];
42 char *keyword, *value;
47 while(fgets(buf,sizeof buf,stdin) != NULL)
50 if(!strncmp(buf,"[AES 128-Key]", 13))
52 else if(!strncmp(buf,"[AES 192-Key]", 13))
54 else if(!strncmp(buf,"[AES 256-Key]", 13))
56 if (!parse_line(&keyword, &value, lbuf, buf))
58 if(!strcmp(keyword,"Key"))
60 key=hex2bin_m(value,&i);
63 fprintf(stderr, "Invalid key length, expecting %ld\n", keylen);
67 else if(!strcmp(keyword,"DT"))
69 dt=hex2bin_m(value,&i);
72 fprintf(stderr, "Invalid DT length\n");
76 else if(!strcmp(keyword,"V"))
78 v=hex2bin_m(value,&i);
81 fprintf(stderr, "Invalid V length\n");
87 fprintf(stderr, "Missing key or DT\n");
91 FIPS_rand_set_key(key, keylen);
94 if (FIPS_rand_bytes(ret,16) <= 0)
96 fprintf(stderr, "Error getting PRNG value\n");
113 unsigned char *key = NULL;
114 unsigned char *v = NULL;
115 unsigned char *dt = NULL;
116 unsigned char ret[16];
119 char *keyword, *value;
125 while(fgets(buf,sizeof buf,stdin) != NULL)
128 if(!strncmp(buf,"[AES 128-Key]", 13))
130 else if(!strncmp(buf,"[AES 192-Key]", 13))
132 else if(!strncmp(buf,"[AES 256-Key]", 13))
134 if (!parse_line(&keyword, &value, lbuf, buf))
136 if(!strcmp(keyword,"Key"))
138 key=hex2bin_m(value,&i);
141 fprintf(stderr, "Invalid key length, expecting %ld\n", keylen);
145 else if(!strcmp(keyword,"DT"))
147 dt=hex2bin_m(value,&i);
150 fprintf(stderr, "Invalid DT length\n");
154 else if(!strcmp(keyword,"V"))
156 v=hex2bin_m(value,&i);
159 fprintf(stderr, "Invalid V length\n");
165 fprintf(stderr, "Missing key or DT\n");
169 FIPS_rand_set_key(key, keylen);
170 FIPS_rand_seed(v,16);
171 for (i = 0; i < 10000; i++)
173 FIPS_rand_set_dt(dt);
174 if (FIPS_rand_bytes(ret,16) <= 0)
176 fprintf(stderr, "Error getting PRNG value\n");
180 for (j = 15; j >= 0; j--)
199 int main(int argc,char **argv)
203 fprintf(stderr,"%s [mct|vst]\n",argv[0]);
206 fips_set_error_print();
207 if(!FIPS_mode_set(1))
210 if (!FIPS_rand_test_mode())
212 fprintf(stderr, "Error setting PRNG test mode\n");
215 if(!strcmp(argv[1],"mct"))
217 else if(!strcmp(argv[1],"vst"))
221 fprintf(stderr,"Don't know how to %s.\n",argv[1]);