+ }
+ if (!EVP_PKEY_set1_DSA(pkey, dsa)) {
+ BIO_printf(bio_err, "unable to associate DSA parameters with PKEY\n");
+ goto end;
+ }
+ ctx = EVP_PKEY_CTX_new(pkey, NULL);
+ if (ctx == NULL) {
+ BIO_printf(bio_err, "unable to create PKEY context\n");
+ goto end;
+ }
+ EVP_PKEY_free(pkey);
+ pkey = NULL;
+ if (EVP_PKEY_keygen_init(ctx) <= 0) {
+ BIO_printf(bio_err, "unable to set up for key generation\n");
+ goto end;
+ }
+ if (verbose)
+ BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
+ if (EVP_PKEY_keygen(ctx, &pkey) <= 0) {
+ BIO_printf(bio_err, "unable to generate key\n");
+ goto end;
+ }