-
Notifications
You must be signed in to change notification settings - Fork 168
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/ec: check private key validity with OpenSSL 3 #565
Conversation
The behavior of EVP_PKEY_public_check changed between OpenSSL 1.1.1 and 3.0 so that it no longer validates the private key. Instead, private keys can be validated through EVP_PKEY_private_check and EVP_PKEY_pairwise_check.
f95c335
to
76d64b4
Compare
Thank you for the report. This affects openssl gem v3.0.x. Let me change the target branch to maint-3.0 (which will be merged to master). |
#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) | ||
GetEC(self, ec); | ||
if (EC_KEY_get0_private_key(ec) == NULL) | ||
goto skip_priv_key; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping for a workaround without using the deprecated EC_KEY
, which we eventually have to get rid of, but this looks necessary at the moment.
|
||
key5 = Fixtures.pkey("p384_invalid") | ||
assert_raise(OpenSSL::PKey::ECError) { key5.check_key } | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally and these assertions pass on OpenSSL 1.1 too (as expected).
The manpage gave me the impression what EVP_PKEY_pairwise_check() does is a superset of both EVP_PKEY_public_check() and EVP_PKEY_private_check(). EVP_PKEY_pairwise_check() is apparently an alias of EVP_PKEY_check() and the latter name is already available in OpenSSL 1.1.1. Could a shorter version like the below work, regardless of the OpenSSL version?
|
I believe it is: all end up calling this function with a different |
I have applied those changes in #580. Thank you! |
The behavior of EVP_PKEY_public_check changed between OpenSSL 1.1.1 and 3.0 so that it no longer validates the private key. Instead, private keys can be validated through EVP_PKEY_private_check and EVP_PKEY_pairwise_check.
This addresses #563