Skip to content

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Dec 12, 2021


pkey: do not check NULL argument in ossl_pkey_new()

Passing NULL to ossl_pkey_new() makes no sense in the first place, and
in fact it is ensured not to be NULL in all cases.


pkey: allocate EVP_PKEY on #initialize

Allocate an EVP_PKEY when the content is ready: when #initialize
or #initialize_copy is called, rather than when a T_DATA is allocated.
This is more natural because the lower level API has been deprecated
and an EVP_PKEY is becoming the minimum unit of handling keys.


pkey: use EVP_PKEY_dup() if available

We can use it to implement OpenSSL::PKey::PKey#initialize_copy. This
should work on all key types, not just DH/DSA/EC/RSA types.

Passing NULL to ossl_pkey_new() makes no sense in the first place, and
in fact it is ensured not to be NULL in all cases.
Allocate an EVP_PKEY when the content is ready: when #initialize
or #initialize_copy is called, rather than when a T_DATA is allocated.
This is more natural because the lower level API has been deprecated
and an EVP_PKEY is becoming the minimum unit of handling keys.
We can use it to implement OpenSSL::PKey::PKey#initialize_copy. This
should work on all key types, not just DH/DSA/EC/RSA types.
@rhenium
Copy link
Member Author

rhenium commented Dec 12, 2021

The third commit ("use EVP_PKEY_dup()") was tested locally on OpenSSL 3.0.0. GitHub Actions will be set up in a later PR.

@rhenium rhenium merged commit 88b7577 into ruby:master Dec 12, 2021
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