version 1.11, 2019/07/14 03:30:45 |
version 1.12, 2021/11/20 18:10:48 |
|
|
|
|
#define DEFBITS 512 |
#define DEFBITS 512 |
|
|
static int dh_cb(int p, int n, BN_GENCB * cb); |
static int dh_cb(int p, int n, BN_GENCB *cb); |
|
|
static struct { |
static struct { |
int g; |
int g; |
|
|
int |
int |
gendh_main(int argc, char **argv) |
gendh_main(int argc, char **argv) |
{ |
{ |
BN_GENCB cb; |
BN_GENCB *cb = NULL; |
DH *dh = NULL; |
DH *dh = NULL; |
int ret = 1, numbits = DEFBITS; |
int ret = 1, numbits = DEFBITS; |
BIO *out = NULL; |
BIO *out = NULL; |
|
|
} |
} |
} |
} |
|
|
BN_GENCB_set(&cb, dh_cb, bio_err); |
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); |
|
|
memset(&gendh_config, 0, sizeof(gendh_config)); |
memset(&gendh_config, 0, sizeof(gendh_config)); |
|
|
gendh_config.g = 2; |
gendh_config.g = 2; |
|
|
BIO_printf(bio_err, "This is going to take a long time\n"); |
BIO_printf(bio_err, "This is going to take a long time\n"); |
|
|
if (((dh = DH_new()) == NULL) || |
if (((dh = DH_new()) == NULL) || |
!DH_generate_parameters_ex(dh, numbits, gendh_config.g, &cb)) |
!DH_generate_parameters_ex(dh, numbits, gendh_config.g, cb)) |
goto end; |
goto end; |
|
|
if (!PEM_write_bio_DHparams(out, dh)) |
if (!PEM_write_bio_DHparams(out, dh)) |
|
|
if (ret != 0) |
if (ret != 0) |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
BIO_free_all(out); |
BIO_free_all(out); |
|
BN_GENCB_free(cb); |
DH_free(dh); |
DH_free(dh); |
|
|
return (ret); |
return (ret); |
} |
} |
|
|
static int |
static int |
dh_cb(int p, int n, BN_GENCB * cb) |
dh_cb(int p, int n, BN_GENCB *cb) |
{ |
{ |
char c = '*'; |
char c = '*'; |
|
|
|
|
c = '*'; |
c = '*'; |
if (p == 3) |
if (p == 3) |
c = '\n'; |
c = '\n'; |
BIO_write(cb->arg, &c, 1); |
BIO_write(BN_GENCB_get_arg(cb), &c, 1); |
(void) BIO_flush(cb->arg); |
(void) BIO_flush(BN_GENCB_get_arg(cb)); |
return 1; |
return 1; |
} |
} |
#endif |
#endif |