Skip to content

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant