OLD | NEW |
1 /* apps/dsaparam.c */ | 1 /* apps/dsaparam.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 #endif | 106 #endif |
107 | 107 |
108 static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *cb); | 108 static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *cb); |
109 | 109 |
110 int MAIN(int, char **); | 110 int MAIN(int, char **); |
111 | 111 |
112 int MAIN(int argc, char **argv) | 112 int MAIN(int argc, char **argv) |
113 { | 113 { |
114 #ifndef OPENSSL_NO_ENGINE | |
115 ENGINE *e = NULL; | |
116 #endif | |
117 DSA *dsa=NULL; | 114 DSA *dsa=NULL; |
118 int i,badops=0,text=0; | 115 int i,badops=0,text=0; |
119 BIO *in=NULL,*out=NULL; | 116 BIO *in=NULL,*out=NULL; |
120 int informat,outformat,noout=0,C=0,ret=1; | 117 int informat,outformat,noout=0,C=0,ret=1; |
121 char *infile,*outfile,*prog,*inrand=NULL; | 118 char *infile,*outfile,*prog,*inrand=NULL; |
122 int numbits= -1,num,genkey=0; | 119 int numbits= -1,num,genkey=0; |
123 int need_rand=0; | 120 int need_rand=0; |
124 #ifndef OPENSSL_NO_ENGINE | 121 #ifndef OPENSSL_NO_ENGINE |
125 char *engine=NULL; | 122 char *engine=NULL; |
126 #endif | 123 #endif |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 else | 268 else |
272 { | 269 { |
273 if (BIO_write_filename(out,outfile) <= 0) | 270 if (BIO_write_filename(out,outfile) <= 0) |
274 { | 271 { |
275 perror(outfile); | 272 perror(outfile); |
276 goto end; | 273 goto end; |
277 } | 274 } |
278 } | 275 } |
279 | 276 |
280 #ifndef OPENSSL_NO_ENGINE | 277 #ifndef OPENSSL_NO_ENGINE |
281 e = setup_engine(bio_err, engine, 0); | 278 setup_engine(bio_err, engine, 0); |
282 #endif | 279 #endif |
283 | 280 |
284 if (need_rand) | 281 if (need_rand) |
285 { | 282 { |
286 app_RAND_load_file(NULL, bio_err, (inrand != NULL)); | 283 app_RAND_load_file(NULL, bio_err, (inrand != NULL)); |
287 if (inrand != NULL) | 284 if (inrand != NULL) |
288 BIO_printf(bio_err,"%ld semi-random bytes loaded\n", | 285 BIO_printf(bio_err,"%ld semi-random bytes loaded\n", |
289 app_RAND_load_files(inrand)); | 286 app_RAND_load_files(inrand)); |
290 } | 287 } |
291 | 288 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } | 347 } |
351 | 348 |
352 if (text) | 349 if (text) |
353 { | 350 { |
354 DSAparams_print(out,dsa); | 351 DSAparams_print(out,dsa); |
355 } | 352 } |
356 | 353 |
357 if (C) | 354 if (C) |
358 { | 355 { |
359 unsigned char *data; | 356 unsigned char *data; |
360 » » int l,len,bits_p,bits_q,bits_g; | 357 » » int l,len,bits_p; |
361 | 358 |
362 len=BN_num_bytes(dsa->p); | 359 len=BN_num_bytes(dsa->p); |
363 bits_p=BN_num_bits(dsa->p); | 360 bits_p=BN_num_bits(dsa->p); |
364 bits_q=BN_num_bits(dsa->q); | |
365 bits_g=BN_num_bits(dsa->g); | |
366 data=(unsigned char *)OPENSSL_malloc(len+20); | 361 data=(unsigned char *)OPENSSL_malloc(len+20); |
367 if (data == NULL) | 362 if (data == NULL) |
368 { | 363 { |
369 perror("OPENSSL_malloc"); | 364 perror("OPENSSL_malloc"); |
370 goto end; | 365 goto end; |
371 } | 366 } |
372 l=BN_bn2bin(dsa->p,data); | 367 l=BN_bn2bin(dsa->p,data); |
373 printf("static unsigned char dsa%d_p[]={",bits_p); | 368 printf("static unsigned char dsa%d_p[]={",bits_p); |
374 for (i=0; i<l; i++) | 369 for (i=0; i<l; i++) |
375 { | 370 { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 #endif | 470 #endif |
476 return 1; | 471 return 1; |
477 } | 472 } |
478 #else /* !OPENSSL_NO_DSA */ | 473 #else /* !OPENSSL_NO_DSA */ |
479 | 474 |
480 # if PEDANTIC | 475 # if PEDANTIC |
481 static void *dummy=&dummy; | 476 static void *dummy=&dummy; |
482 # endif | 477 # endif |
483 | 478 |
484 #endif | 479 #endif |
OLD | NEW |