=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/dhparam.c,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** src/usr.bin/openssl/dhparam.c 2019/07/14 03:30:45 1.12 --- src/usr.bin/openssl/dhparam.c 2021/11/20 18:10:48 1.13 *************** *** 1,4 **** ! /* $OpenBSD: dhparam.c,v 1.12 2019/07/14 03:30:45 guenther Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * --- 1,4 ---- ! /* $OpenBSD: dhparam.c,v 1.13 2021/11/20 18:10:48 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * *************** *** 231,242 **** options_usage(dhparam_options); } ! static int dh_cb(int p, int n, BN_GENCB * cb); int dhparam_main(int argc, char **argv) { BIO *in = NULL, *out = NULL; char *num_bits = NULL; DH *dh = NULL; int num = 0; --- 231,243 ---- options_usage(dhparam_options); } ! static int dh_cb(int p, int n, BN_GENCB *cb); int dhparam_main(int argc, char **argv) { BIO *in = NULL, *out = NULL; + BN_GENCB *cb = NULL; char *num_bits = NULL; DH *dh = NULL; int num = 0; *************** *** 283,297 **** } if (num) { ! BN_GENCB cb; ! BN_GENCB_set(&cb, dh_cb, bio_err); if (dhparam_config.dsaparam) { DSA *dsa = DSA_new(); BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", num); if (!dsa || !DSA_generate_parameters_ex(dsa, num, ! NULL, 0, NULL, NULL, &cb)) { DSA_free(dsa); ERR_print_errors(bio_err); goto end; --- 284,302 ---- } if (num) { + if ((cb = BN_GENCB_new()) == NULL) { + BIO_printf(bio_err, + "Error allocating BN_GENCB object\n"); + goto end; + } ! BN_GENCB_set(cb, dh_cb, bio_err); if (dhparam_config.dsaparam) { DSA *dsa = DSA_new(); BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", num); if (!dsa || !DSA_generate_parameters_ex(dsa, num, ! NULL, 0, NULL, NULL, cb)) { DSA_free(dsa); ERR_print_errors(bio_err); goto end; *************** *** 306,312 **** dh = DH_new(); BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, dhparam_config.g); BIO_printf(bio_err, "This is going to take a long time\n"); ! if (!dh || !DH_generate_parameters_ex(dh, num, dhparam_config.g, &cb)) { ERR_print_errors(bio_err); goto end; } --- 311,317 ---- dh = DH_new(); BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, dhparam_config.g); BIO_printf(bio_err, "This is going to take a long time\n"); ! if (!dh || !DH_generate_parameters_ex(dh, num, dhparam_config.g, cb)) { ERR_print_errors(bio_err); goto end; } *************** *** 469,474 **** --- 474,480 ---- end: BIO_free(in); BIO_free_all(out); + BN_GENCB_free(cb); DH_free(dh); return (ret); *************** *** 476,482 **** /* dh_cb is identical to dsa_cb in apps/dsaparam.c */ static int ! dh_cb(int p, int n, BN_GENCB * cb) { char c = '*'; --- 482,488 ---- /* dh_cb is identical to dsa_cb in apps/dsaparam.c */ static int ! dh_cb(int p, int n, BN_GENCB *cb) { char c = '*'; *************** *** 488,495 **** c = '*'; if (p == 3) c = '\n'; ! BIO_write(cb->arg, &c, 1); ! (void) BIO_flush(cb->arg); return 1; } --- 494,501 ---- c = '*'; if (p == 3) c = '\n'; ! BIO_write(BN_GENCB_get_arg(cb), &c, 1); ! (void) BIO_flush(BN_GENCB_get_arg(cb)); return 1; }