# include <openssl/x509.h>
# include <openssl/pem.h>
-# ifdef GENCB_TEST
-
-static int stop_keygen_flag = 0;
-
-static void timebomb_sigalarm(int foo)
-{
- stop_keygen_flag = 1;
-}
-
-# endif
-
static int dsa_cb(int p, int n, BN_GENCB *cb);
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C,
- OPT_NOOUT, OPT_GENKEY, OPT_RAND, OPT_ENGINE,
- OPT_TIMEBOMB
+ OPT_NOOUT, OPT_GENKEY, OPT_RAND, OPT_ENGINE
} OPTION_CHOICE;
const OPTIONS dsaparam_options[] = {
{"noout", OPT_NOOUT, '-', "No output"},
{"genkey", OPT_GENKEY, '-', "Generate a DSA key"},
{"rand", OPT_RAND, 's', "Files to use for random number input"},
-# ifdef GENCB_TEST
- {"timebomb", OPT_TIMEBOMB, 'p', "Interrupt keygen after 'pnum' seconds"},
-# endif
# ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
# endif
int numbits = -1, num = 0, genkey = 0, need_rand = 0;
int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0;
int ret = 1, i, text = 0, private = 0;
-# ifdef GENCB_TEST
- int timebomb = 0;
-# endif
char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
OPTION_CHOICE o;
case OPT_ENGINE:
e = setup_engine(opt_arg(), 0);
break;
- case OPT_TIMEBOMB:
-# ifdef GENCB_TEST
- timebomb = atoi(opt_arg());
- break;
-# endif
case OPT_TEXT:
text = 1;
break;
BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
num);
BIO_printf(bio_err, "This could take some time\n");
-# ifdef GENCB_TEST
- if (timebomb > 0) {
- struct sigaction act;
- act.sa_handler = timebomb_sigalarm;
- act.sa_flags = 0;
- BIO_printf(bio_err,
- "(though I'll stop it if not done within %d secs)\n",
- timebomb);
- if (sigaction(SIGALRM, &act, NULL) != 0) {
- BIO_printf(bio_err, "Error, couldn't set SIGALRM handler\n");
- goto end;
- }
- alarm(timebomb);
- }
-# endif
if (!DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL, cb)) {
-# ifdef GENCB_TEST
- if (stop_keygen_flag) {
- BIO_printf(bio_err, "DSA key generation time-stopped\n");
- /* This is an asked-for behaviour! */
- ret = 0;
- goto end;
- }
-# endif
ERR_print_errors(bio_err);
BIO_printf(bio_err, "Error, DSA key generation failed\n");
goto end;
c = '\n';
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
(void)BIO_flush(BN_GENCB_get_arg(cb));
-# ifdef GENCB_TEST
- if (stop_keygen_flag)
- return 0;
-# endif
return 1;
}
#endif