diff options
Diffstat (limited to 'src/usr.bin/openssl/dsaparam.c')
-rw-r--r-- | src/usr.bin/openssl/dsaparam.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/usr.bin/openssl/dsaparam.c b/src/usr.bin/openssl/dsaparam.c index 3c2ac89800..3a907fe620 100644 --- a/src/usr.bin/openssl/dsaparam.c +++ b/src/usr.bin/openssl/dsaparam.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsaparam.c,v 1.11 2019/07/14 03:30:45 guenther Exp $ */ | 1 | /* $OpenBSD: dsaparam.c,v 1.12 2021/11/20 18:10:48 tb Exp $ */ |
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 | * |
@@ -156,7 +156,7 @@ dsaparam_usage(void) | |||
156 | options_usage(dsaparam_options); | 156 | options_usage(dsaparam_options); |
157 | } | 157 | } |
158 | 158 | ||
159 | static int dsa_cb(int p, int n, BN_GENCB * cb); | 159 | static int dsa_cb(int p, int n, BN_GENCB *cb); |
160 | 160 | ||
161 | int | 161 | int |
162 | dsaparam_main(int argc, char **argv) | 162 | dsaparam_main(int argc, char **argv) |
@@ -164,6 +164,7 @@ dsaparam_main(int argc, char **argv) | |||
164 | DSA *dsa = NULL; | 164 | DSA *dsa = NULL; |
165 | int i; | 165 | int i; |
166 | BIO *in = NULL, *out = NULL; | 166 | BIO *in = NULL, *out = NULL; |
167 | BN_GENCB *cb = NULL; | ||
167 | int ret = 1; | 168 | int ret = 1; |
168 | int numbits = -1; | 169 | int numbits = -1; |
169 | char *strbits = NULL; | 170 | char *strbits = NULL; |
@@ -218,8 +219,14 @@ dsaparam_main(int argc, char **argv) | |||
218 | } | 219 | } |
219 | 220 | ||
220 | if (numbits > 0) { | 221 | if (numbits > 0) { |
221 | BN_GENCB cb; | 222 | if ((cb = BN_GENCB_new()) == NULL) { |
222 | BN_GENCB_set(&cb, dsa_cb, bio_err); | 223 | BIO_printf(bio_err, |
224 | "Error allocating BN_GENCB object\n"); | ||
225 | goto end; | ||
226 | } | ||
227 | |||
228 | BN_GENCB_set(cb, dsa_cb, bio_err); | ||
229 | |||
223 | dsa = DSA_new(); | 230 | dsa = DSA_new(); |
224 | if (!dsa) { | 231 | if (!dsa) { |
225 | BIO_printf(bio_err, "Error allocating DSA object\n"); | 232 | BIO_printf(bio_err, "Error allocating DSA object\n"); |
@@ -227,7 +234,7 @@ dsaparam_main(int argc, char **argv) | |||
227 | } | 234 | } |
228 | BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", numbits); | 235 | BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", numbits); |
229 | BIO_printf(bio_err, "This could take some time\n"); | 236 | BIO_printf(bio_err, "This could take some time\n"); |
230 | if (!DSA_generate_parameters_ex(dsa, numbits, NULL, 0, NULL, NULL, &cb)) { | 237 | if (!DSA_generate_parameters_ex(dsa, numbits, NULL, 0, NULL, NULL, cb)) { |
231 | ERR_print_errors(bio_err); | 238 | ERR_print_errors(bio_err); |
232 | BIO_printf(bio_err, "Error, DSA key generation failed\n"); | 239 | BIO_printf(bio_err, "Error, DSA key generation failed\n"); |
233 | goto end; | 240 | goto end; |
@@ -341,13 +348,14 @@ dsaparam_main(int argc, char **argv) | |||
341 | end: | 348 | end: |
342 | BIO_free(in); | 349 | BIO_free(in); |
343 | BIO_free_all(out); | 350 | BIO_free_all(out); |
351 | BN_GENCB_free(cb); | ||
344 | DSA_free(dsa); | 352 | DSA_free(dsa); |
345 | 353 | ||
346 | return (ret); | 354 | return (ret); |
347 | } | 355 | } |
348 | 356 | ||
349 | static int | 357 | static int |
350 | dsa_cb(int p, int n, BN_GENCB * cb) | 358 | dsa_cb(int p, int n, BN_GENCB *cb) |
351 | { | 359 | { |
352 | char c = '*'; | 360 | char c = '*'; |
353 | 361 | ||
@@ -359,8 +367,8 @@ dsa_cb(int p, int n, BN_GENCB * cb) | |||
359 | c = '*'; | 367 | c = '*'; |
360 | if (p == 3) | 368 | if (p == 3) |
361 | c = '\n'; | 369 | c = '\n'; |
362 | BIO_write(cb->arg, &c, 1); | 370 | BIO_write(BN_GENCB_get_arg(cb), &c, 1); |
363 | (void) BIO_flush(cb->arg); | 371 | (void) BIO_flush(BN_GENCB_get_arg(cb)); |
364 | #ifdef GENCB_TEST | 372 | #ifdef GENCB_TEST |
365 | if (stop_keygen_flag) | 373 | if (stop_keygen_flag) |
366 | return 0; | 374 | return 0; |