62 #ifdef OPENSSL_NO_DEPRECATED
63 #undef OPENSSL_NO_DEPRECATED
66 #ifndef OPENSSL_NO_DSA
81 #define PROG dsaparam_main
99 static int stop_keygen_flag = 0;
101 static void timebomb_sigalarm(
int foo)
103 stop_keygen_flag = 1;
110 int MAIN(
int,
char **);
112 int MAIN(
int argc,
char **argv)
115 int i,badops=0,
text=0;
117 int informat,outformat,noout=0,C=0,ret=1;
118 char *infile,*outfile,*prog,*inrand=NULL;
119 int numbits= -1,
num,genkey=0;
121 #ifndef OPENSSL_NO_ENGINE
147 if (strcmp(*argv,
"-inform") == 0)
149 if (--argc < 1)
goto bad;
152 else if (strcmp(*argv,
"-outform") == 0)
154 if (--argc < 1)
goto bad;
157 else if (strcmp(*argv,
"-in") == 0)
159 if (--argc < 1)
goto bad;
162 else if (strcmp(*argv,
"-out") == 0)
164 if (--argc < 1)
goto bad;
167 #ifndef OPENSSL_NO_ENGINE
168 else if(strcmp(*argv,
"-engine") == 0)
170 if (--argc < 1)
goto bad;
175 else if(strcmp(*argv,
"-timebomb") == 0)
177 if (--argc < 1)
goto bad;
178 timebomb = atoi(*(++argv));
181 else if (strcmp(*argv,
"-text") == 0)
183 else if (strcmp(*argv,
"-C") == 0)
185 else if (strcmp(*argv,
"-genkey") == 0)
190 else if (strcmp(*argv,
"-rand") == 0)
192 if (--argc < 1)
goto bad;
196 else if (strcmp(*argv,
"-noout") == 0)
198 else if (sscanf(*argv,
"%d",&
num) == 1)
228 #ifndef OPENSSL_NO_ENGINE
234 BIO_printf(
bio_err,
" number number of bits to use for generating private key\n");
242 if ((in == NULL) || (out == NULL))
261 #ifdef OPENSSL_SYS_VMS
277 #ifndef OPENSSL_NO_ENGINE
305 struct sigaction act;
306 act.sa_handler = timebomb_sigalarm;
310 if(sigaction(SIGALRM, &act, NULL) != 0)
336 dsa=PEM_read_bio_DSAparams(in,NULL,NULL,NULL);
364 perror(
"OPENSSL_malloc");
368 printf(
"static unsigned char dsa%d_p[]={",bits_p);
371 if ((i%12) == 0) printf(
"\n\t");
372 printf(
"0x%02X,",data[i]);
377 printf(
"static unsigned char dsa%d_q[]={",bits_p);
380 if ((i%12) == 0) printf(
"\n\t");
381 printf(
"0x%02X,",data[i]);
386 printf(
"static unsigned char dsa%d_g[]={",bits_p);
389 if ((i%12) == 0) printf(
"\n\t");
390 printf(
"0x%02X,",data[i]);
392 printf(
"\n\t};\n\n");
394 printf(
"DSA *get_dsa%d()\n\t{\n",bits_p);
395 printf(
"\tDSA *dsa;\n\n");
396 printf(
"\tif ((dsa=DSA_new()) == NULL) return(NULL);\n");
397 printf(
"\tdsa->p=BN_bin2bn(dsa%d_p,sizeof(dsa%d_p),NULL);\n",
399 printf(
"\tdsa->q=BN_bin2bn(dsa%d_q,sizeof(dsa%d_q),NULL);\n",
401 printf(
"\tdsa->g=BN_bin2bn(dsa%d_g,sizeof(dsa%d_g),NULL);\n",
403 printf(
"\tif ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))\n");
404 printf(
"\t\t{ DSA_free(dsa); return(NULL); }\n");
405 printf(
"\treturn(dsa);\n\t}\n");
414 i=PEM_write_bio_DSAparams(out,dsa);
436 i=PEM_write_bio_DSAPrivateKey(out,dsakey,NULL,NULL,0,NULL,NULL);
476 static void *dummy=&dummy;