Have all algorithm test programs call fips_algtest_init() at startup:
this will perform all standalone operations such as setting error callbacks, entering FIPS mode etc.
This commit is contained in:
parent
d4178c8fb1
commit
cd22dfbf01
@ -867,12 +867,8 @@ int main(int argc, char **argv)
|
|||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
char fn[250] = "", rfn[256] = "";
|
char fn[250] = "", rfn[256] = "";
|
||||||
int f_opt = 0, d_opt = 1;
|
int f_opt = 0, d_opt = 1;
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
|
|
||||||
#ifdef OPENSSL_FIPS
|
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
EXIT(1);
|
|
||||||
#endif
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
if (strcasecmp(argv[1], "-d") == 0)
|
if (strcasecmp(argv[1], "-d") == 0)
|
||||||
|
@ -292,9 +292,7 @@ int main(int argc,char **argv)
|
|||||||
fprintf(stderr,"%s [-encrypt|-decrypt]\n",argv[0]);
|
fprintf(stderr,"%s [-encrypt|-decrypt]\n",argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
exit(1);
|
|
||||||
if(!strcmp(argv[1],"-encrypt"))
|
if(!strcmp(argv[1],"-encrypt"))
|
||||||
encrypt = 1;
|
encrypt = 1;
|
||||||
else if(!strcmp(argv[1],"-encryptIVext"))
|
else if(!strcmp(argv[1],"-encryptIVext"))
|
||||||
|
@ -102,9 +102,7 @@ int main(int argc, char **argv)
|
|||||||
int known_keylen = 0; /* Only set when Klen_counts_keys = 1 */
|
int known_keylen = 0; /* Only set when Klen_counts_keys = 1 */
|
||||||
const EVP_CIPHER *cipher = 0;
|
const EVP_CIPHER *cipher = 0;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
while (argc > 1 && argv[1][0] == '-')
|
while (argc > 1 && argv[1][0] == '-')
|
||||||
{
|
{
|
||||||
|
@ -633,11 +633,7 @@ int main(int argc, char **argv)
|
|||||||
char fn[250] = "", rfn[256] = "";
|
char fn[250] = "", rfn[256] = "";
|
||||||
int f_opt = 0, d_opt = 1;
|
int f_opt = 0, d_opt = 1;
|
||||||
|
|
||||||
#ifdef OPENSSL_FIPS
|
fips_algtest_init();
|
||||||
fips_set_error_print();
|
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
EXIT(1);
|
|
||||||
#endif
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
if (strcasecmp(argv[1], "-d") == 0)
|
if (strcasecmp(argv[1], "-d") == 0)
|
||||||
|
@ -160,9 +160,7 @@ int main(int argc,char **argv)
|
|||||||
char *keyword = NULL, *value = NULL;
|
char *keyword = NULL, *value = NULL;
|
||||||
int do_verify = -1, exout = 0;
|
int do_verify = -1, exout = 0;
|
||||||
|
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
if (argn && !strcmp(*args, "dhver"))
|
if (argn && !strcmp(*args, "dhver"))
|
||||||
{
|
{
|
||||||
|
@ -156,9 +156,7 @@ int main(int argc, char **argv)
|
|||||||
BN_GENCB_set(&cb, dsa_cb, stderr);
|
BN_GENCB_set(&cb, dsa_cb, stderr);
|
||||||
FIPS_md_ctx_init(&mctx);
|
FIPS_md_ctx_init(&mctx);
|
||||||
|
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
EXIT(1);
|
|
||||||
|
|
||||||
fprintf(stderr,"test generation of DSA parameters\n");
|
fprintf(stderr,"test generation of DSA parameters\n");
|
||||||
|
|
||||||
|
@ -626,9 +626,7 @@ int main(int argc,char **argv)
|
|||||||
fprintf(stderr,"%s [prime|pqg|pqgver|keypair|keyver|siggen|sigver]\n",argv[0]);
|
fprintf(stderr,"%s [prime|pqg|pqgver|keypair|keyver|siggen|sigver]\n",argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
exit(1);
|
|
||||||
if(!strcmp(argv[1],"prime"))
|
if(!strcmp(argv[1],"prime"))
|
||||||
primes(in, out);
|
primes(in, out);
|
||||||
else if(!strcmp(argv[1],"pqg"))
|
else if(!strcmp(argv[1],"pqg"))
|
||||||
|
@ -291,9 +291,7 @@ int main(int argc,char **argv)
|
|||||||
int curve_nids[5] = {0,0,0,0,0};
|
int curve_nids[5] = {0,0,0,0,0};
|
||||||
int param_set = -1;
|
int param_set = -1;
|
||||||
|
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
if (argn && !strcmp(*args, "ecdhver"))
|
if (argn && !strcmp(*args, "ecdhver"))
|
||||||
{
|
{
|
||||||
|
@ -463,9 +463,7 @@ int main(int argc, char **argv)
|
|||||||
FILE *in = NULL, *out = NULL;
|
FILE *in = NULL, *out = NULL;
|
||||||
const char *cmd = argv[1];
|
const char *cmd = argv[1];
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if (!FIPS_mode_set(1))
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
if (argc == 4)
|
if (argc == 4)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,7 @@ int bint2bin(const char *in, int len, unsigned char *out);
|
|||||||
int bin2bint(const unsigned char *in,int len,char *out);
|
int bin2bint(const unsigned char *in,int len,char *out);
|
||||||
void PrintValue(char *tag, unsigned char *val, int len);
|
void PrintValue(char *tag, unsigned char *val, int len);
|
||||||
void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode);
|
void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode);
|
||||||
|
void fips_algtest_init(void);
|
||||||
|
|
||||||
static int no_err;
|
static int no_err;
|
||||||
|
|
||||||
@ -97,6 +98,16 @@ static void fips_set_error_print(void)
|
|||||||
FIPS_set_error_callbacks(put_err_cb, add_err_cb);
|
FIPS_set_error_callbacks(put_err_cb, add_err_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fips_algtest_init(void)
|
||||||
|
{
|
||||||
|
fips_set_error_print();
|
||||||
|
if (!FIPS_mode_set(1))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error entering FIPS mode\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int hex2bin(const char *in, unsigned char *out)
|
int hex2bin(const char *in, unsigned char *out)
|
||||||
{
|
{
|
||||||
int n1, n2, isodd = 0;
|
int n1, n2, isodd = 0;
|
||||||
|
@ -90,9 +90,7 @@ int main(int argc, char **argv)
|
|||||||
FILE *in = NULL, *out = NULL;
|
FILE *in = NULL, *out = NULL;
|
||||||
|
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
in = stdin;
|
in = stdin;
|
||||||
|
@ -172,7 +172,7 @@ int main(int argc,char **argv)
|
|||||||
|
|
||||||
int gen = 0;
|
int gen = 0;
|
||||||
|
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
|
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
{
|
{
|
||||||
|
@ -241,7 +241,7 @@ static void run_test(unsigned char *key, int keylen, AES_PRNG_MCT *tv)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
run_test(aes_128_mct_key, 16, &aes_128_mct_tv);
|
run_test(aes_128_mct_key, 16, &aes_128_mct_tv);
|
||||||
printf("FIPS PRNG test 1 done\n");
|
printf("FIPS PRNG test 1 done\n");
|
||||||
run_test(aes_192_mct_key, 24, &aes_192_mct_tv);
|
run_test(aes_192_mct_key, 24, &aes_192_mct_tv);
|
||||||
|
@ -226,9 +226,7 @@ int main(int argc,char **argv)
|
|||||||
fprintf(stderr,"%s [mct|vst]\n",argv[0]);
|
fprintf(stderr,"%s [mct|vst]\n",argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
exit(1);
|
|
||||||
FIPS_rand_reset();
|
FIPS_rand_reset();
|
||||||
if (!FIPS_rand_test_mode())
|
if (!FIPS_rand_test_mode())
|
||||||
{
|
{
|
||||||
|
@ -94,9 +94,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
in = stdin;
|
in = stdin;
|
||||||
|
@ -91,9 +91,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
int ret = 1, Saltlen = -1;
|
int ret = 1, Saltlen = -1;
|
||||||
|
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if ((argc > 2) && !strcmp("-saltlen", argv[1]))
|
if ((argc > 2) && !strcmp("-saltlen", argv[1]))
|
||||||
{
|
{
|
||||||
|
@ -96,9 +96,7 @@ int main(int argc, char **argv)
|
|||||||
int ret = 1;
|
int ret = 1;
|
||||||
int Saltlen = -1;
|
int Saltlen = -1;
|
||||||
|
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if ((argc > 2) && !strcmp("-saltlen", argv[1]))
|
if ((argc > 2) && !strcmp("-saltlen", argv[1]))
|
||||||
{
|
{
|
||||||
|
@ -91,9 +91,7 @@ int main(int argc, char **argv)
|
|||||||
FILE *in = NULL, *out = NULL;
|
FILE *in = NULL, *out = NULL;
|
||||||
|
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
fips_set_error_print();
|
fips_algtest_init();
|
||||||
if(!FIPS_mode_set(1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
in = stdin;
|
in = stdin;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user