Skip to content
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

pkey: disallow {DH,DSA,EC,RSA}.new without arguments on OpenSSL 3.0 #848

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Jan 29, 2025

When OpenSSL::PKey::{DH,DSA,EC,RSA}.new is called without any arguments, it sets up an empty corresponding low-level struct and wraps it in an EVP_PKEY. This form has been supported so that users can fill the fields later using low-level setter methods such as OpenSSL::PKey::RSA#set_key.

Such setter methods are not compatible with OpenSSL 3.0 or later, where pkeys are immutable once created. This means that the ability to create an empty instance is useless. Let's remove it and raise ArgumentError if attempted.

Related:

Introduce a useful macro to avoid scattering *_PREREQ() checks
everywhere.

Currently, the macro is defined for OpenSSL 3.0 or later only. I think
it is possible that LibreSSL may adopt it in the future.
When OpenSSL::PKey::{DH,DSA,EC,RSA}.new is called without any arguments,
it sets up an empty corresponding low-level struct and wraps it in an
EVP_PKEY. This form has been supported so that users can fill the fields
later using low-level setter methods such as OpenSSL::PKey::RSA#set_key.

Such setter methods are not compatible with OpenSSL 3.0 or later, where
pkeys are immutable once created. This means that the ability to create
an empty instance is useless. Let's remove it and raise ArgumentError if
attempted.
@rhenium rhenium force-pushed the ky/pkey-disallow-empty-init branch from 63e9d09 to 43aa5ca Compare January 30, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant