FILE *fp = NULL;
char fn[250] = "", rfn[256] = "";
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 (strcasecmp(argv[1], "-d") == 0)
fprintf(stderr,"%s [-encrypt|-decrypt]\n",argv[0]);
exit(1);
}
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- exit(1);
+ fips_algtest_init();
if(!strcmp(argv[1],"-encrypt"))
encrypt = 1;
else if(!strcmp(argv[1],"-encryptIVext"))
int known_keylen = 0; /* Only set when Klen_counts_keys = 1 */
const EVP_CIPHER *cipher = 0;
int ret = 1;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- goto end;
+ fips_algtest_init();
while (argc > 1 && argv[1][0] == '-')
{
char fn[250] = "", rfn[256] = "";
int f_opt = 0, d_opt = 1;
-#ifdef OPENSSL_FIPS
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- EXIT(1);
-#endif
+ fips_algtest_init();
if (argc > 1)
{
if (strcasecmp(argv[1], "-d") == 0)
char *keyword = NULL, *value = NULL;
int do_verify = -1, exout = 0;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- exit(1);
+ fips_algtest_init();
if (argn && !strcmp(*args, "dhver"))
{
BN_GENCB_set(&cb, dsa_cb, stderr);
FIPS_md_ctx_init(&mctx);
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- EXIT(1);
+ fips_algtest_init();
fprintf(stderr,"test generation of DSA parameters\n");
fprintf(stderr,"%s [prime|pqg|pqgver|keypair|keyver|siggen|sigver]\n",argv[0]);
exit(1);
}
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- exit(1);
+ fips_algtest_init();
if(!strcmp(argv[1],"prime"))
primes(in, out);
else if(!strcmp(argv[1],"pqg"))
int curve_nids[5] = {0,0,0,0,0};
int param_set = -1;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- exit(1);
+ fips_algtest_init();
if (argn && !strcmp(*args, "ecdhver"))
{
FILE *in = NULL, *out = NULL;
const char *cmd = argv[1];
int rv = 0;
- fips_set_error_print();
- if (!FIPS_mode_set(1))
- exit(1);
+ fips_algtest_init();
if (argc == 4)
{
int bin2bint(const unsigned char *in,int len,char *out);
void PrintValue(char *tag, unsigned char *val, int len);
void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode);
+void fips_algtest_init(void);
static int no_err;
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 n1, n2, isodd = 0;
FILE *in = NULL, *out = NULL;
int ret = 1;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- goto end;
+ fips_algtest_init();
if (argc == 1)
in = stdin;
int gen = 0;
- fips_set_error_print();
+ fips_algtest_init();
if (argc == 3)
{
int main()
{
- fips_set_error_print();
+ fips_algtest_init();
run_test(aes_128_mct_key, 16, &aes_128_mct_tv);
printf("FIPS PRNG test 1 done\n");
run_test(aes_192_mct_key, 24, &aes_192_mct_tv);
fprintf(stderr,"%s [mct|vst]\n",argv[0]);
exit(1);
}
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- exit(1);
+ fips_algtest_init();
FIPS_rand_reset();
if (!FIPS_rand_test_mode())
{
int ret = 1;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- goto end;
+ fips_algtest_init();
if (argc == 1)
in = stdin;
int ret = 1, Saltlen = -1;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- goto end;
+ fips_algtest_init();
if ((argc > 2) && !strcmp("-saltlen", argv[1]))
{
int ret = 1;
int Saltlen = -1;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- goto end;
+ fips_algtest_init();
if ((argc > 2) && !strcmp("-saltlen", argv[1]))
{
FILE *in = NULL, *out = NULL;
int ret = 1;
- fips_set_error_print();
- if(!FIPS_mode_set(1))
- goto end;
+ fips_algtest_init();
if (argc == 1)
in = stdin;