main() { DH *dh; dh=DH_new(); dh->p=BN_bin2bn(data,sizeof(data),NULL); dh->g=BN_new(); BN_set_word(dh->g,2); PEM_write_DHparams(stdout,dh); }
main() { DH *dh; dh=DH_new(); dh->p=BN_bin2bn(data,sizeof(data),NULL); dh->g=BN_new(); BN_set_word(dh->g,2); PEM_write_DHparams(OPENSSL_TYPE__FILE_STDOUT,dh); }
int generate_dhparam(int dh_bits) { DH * dh ; char filename[FIELD_SZ+1]; FILE * out; sprintf(filename, "dh%d.pem", dh_bits); if ((out=fopen(filename, "wb"))==NULL) { fprintf(stderr, "Cannot create %s: aborting\n", filename); return -1; } dh = DH_new(); printf("Generating DH parameters (%d bits) -- this can take long\n", dh_bits); DH_generate_parameters_ex(dh, dh_bits, DH_GENERATOR_2, 0); PEM_write_DHparams(out, dh); fclose(out); printf("done\n"); return 0; }
inline void dh_key::write_parameters(file _file) const { throw_error_if_not(PEM_write_DHparams(_file.raw(), ptr().get()) != 0); }