#endif
OPT_F4, OPT_ENGINE,
OPT_OUT, OPT_PASSOUT, OPT_CIPHER, OPT_PRIMES, OPT_VERBOSE,
- OPT_R_ENUM, OPT_PROV_ENUM
+ OPT_R_ENUM, OPT_PROV_ENUM, OPT_TRADITIONAL
} OPTION_CHOICE;
const OPTIONS genrsa_options[] = {
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
{"primes", OPT_PRIMES, 'p', "Specify number of primes"},
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
+ {"traditional", OPT_TRADITIONAL, '-',
+ "Use traditional format for private keys"},
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
OPT_R_OPTIONS,
char *outfile = NULL, *passoutarg = NULL, *passout = NULL;
char *prog, *hexe, *dece;
OPTION_CHOICE o;
- unsigned char *ebuf = NULL;
+ int traditional = 0;
if (bn == NULL || cb == NULL)
goto end;
case OPT_VERBOSE:
verbose = 1;
break;
+ case OPT_TRADITIONAL:
+ traditional = 1;
+ break;
}
}
argc = opt_num_rest();
BIO_printf(bio_err, "Error allocating RSA public exponent\n");
goto end;
}
- if (EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, bn) <= 0) {
+ if (EVP_PKEY_CTX_set1_rsa_keygen_pubexp(ctx, bn) <= 0) {
BIO_printf(bio_err, "Error setting RSA public exponent\n");
goto end;
}
OPENSSL_free(hexe);
OPENSSL_free(dece);
}
- if (!PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, passout))
- goto end;
+ if (traditional) {
+ if (!PEM_write_bio_PrivateKey_traditional(out, pkey, enc, NULL, 0,
+ NULL, passout))
+ goto end;
+ } else {
+ if (!PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, passout))
+ goto end;
+ }
ret = 0;
end:
BIO_free_all(out);
release_engine(eng);
OPENSSL_free(passout);
- OPENSSL_free(ebuf);
if (ret != 0)
ERR_print_errors(bio_err);
return ret;