Skip to content

doc: update documentation to be clearer about how to use OpenSSL 3.x API #915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcr
Copy link
Contributor

@mcr mcr commented Jul 26, 2025

This adds a few more clues to the documentation, as the straight reference to the genpkey didn't help me update from openssl 1. to openssl 3.

Comment on lines 462 to +473
* For the supported options, see the documentation for the 'openssl genpkey'
* utility command.
* utility command, visible as the manpage genpkey(1).
*
* The algorithm name will generally be RSA, DSA, EC, or DH.
* EcDSA keys are of type "EC" (not DSA), but have an 'ec_paramgen_curve' value
* set to values like secp384r1 or prime256v1.
* Note that the genpkey manpage can be mis-read to suggest it is
* 'ec_paramgen_curve:curve', but that incorrect, on the command line the colon
* separates the key from value.
*
* RSA keys are of type "RSA", and have a parameter "rsa_keygen_bits"
* giving the strength.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add to the confusion, these names became outdated with OpenSSL 3: "rsa_keygen_bits" was renamed to "bits" and "ec_paramgen_curve" to "group". This is documented in EVP_PKEY-RSA(7) and EVP_PKEY-EC(7), but openssl-genpkey(1) appears to have fallen out of sync.

I'd prefer not to document about specific algorithms here, as the ctrl names don't appear to be stable. I think we should encourage to read the relevant man pages themselves.

Given that it's outdated, we should still update the references. I'd suggest something like

 * See also the man page EVP_PKEY_generate(3). For supported options, refer to
 * the corresponding man page for the algorithm, such as EVP_PKEY-RSA(7).
 *
 * For DSA, DH, EC, and RSA, each subclass provides a +generate+ method as a
 * shorthand for key generation.

For the 4 key types, we have OpenSSL::PKey::{RSA,DSA,EC,DH}.generate as a convenient class method. It might be worth mentioning.

@@ -503,6 +503,9 @@ ossl_ec_key_to_der(VALUE self)
*
* See also the OpenSSL documentation for EC_KEY_generate_key()
*
* With OpenSSL 3.0, PKEY objects are immutable, so to generate a new keypair,
* use OpenSSL::PKey.generate_key("EC", "ec_paramgen_curve" => "prime256v1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* use OpenSSL::PKey.generate_key("EC", "ec_paramgen_curve" => "prime256v1")
* use <tt>OpenSSL::PKey::EC.generate("prime256v1")</tt>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants