-
Notifications
You must be signed in to change notification settings - Fork 172
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
ossl_pkey.c: Workaround: Decode with non-zero selections. #669
ossl_pkey.c: Workaround: Decode with non-zero selections. #669
Conversation
The workaround seems straightforward. Do you expect any difference in the behavior with explicitly specifying selections compared to using the "0" selection? I'm wondering if we can just continue to use the workaround code on all OpenSSL >= 3.0 versions even with the bugfix. Unless it's necessary and we are sure it's safe to do, I prefer not to rely on the version number in the library code. We know distros often backport individual patches to OpenSSL without updating version numbers. |
All right. I can understand your point. My concern for using non-zero selections was a performance in the case trying to call the
With selection 0.
With non-zero selections.
I will rebase this PR on your way. |
41427bd
to
4cc7a6b
Compare
Rebased this PR! |
4cc7a6b
to
d7e40bb
Compare
d7e40bb
to
161a0b9
Compare
I suspect this example is mostly measuring the time spent for Ruby and OpenSSL's initialization, but I don't think performance is a big concern here. I wanted to know if this doesn't change the decoding result. The test cases are successful, so I guess it's OK. |
Ah I see. And yeah, the test cases are successful. |
Because we will add a workaround to avoid this issue.
This is a workaround for the decoding issue in ossl_pkey_read_generic(). The issue happens in the case that a key management provider is different from a decoding provider. Try all the non-zero selections in order, instead of selection 0 for OpenSSL 3 to avoid the issue.
161a0b9
to
db688fa
Compare
I am rebasing by fixing the mentioned items. Could you review again? Thanks. |
* | ||
* See https://github.com/openssl/openssl/pull/21519 for details. | ||
* | ||
* First check for private key formats (EVP_PKEY_KEYPAIR). This is to keep |
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 added the (EVP_PKEY_KEYPAIR)
here to explain why we need to check the EVP_PKEY_KEYPAIR
case first.
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.
Tests passed successfully on all versions. I think this is good to merge!
Thanks for reviewing! |
This PR has 3 commits.
The 1st commit is to remove the pending method pend_on_openssl_issue_21493. The 2nd commit is the same with this PR #668. I will rebase this PR after the PR #668 is merged. It's needed by the 3rd commit. And the 3rd commit is a workaround for the issue openssl/openssl#21519, in the cases of the affected OpenSSL release versions.
I was thinking about my previous PR #664 to pend the related tests. And failing
OpenSSL::PKey.read(der_encoded_string)
with selection 0 is quite basic use case, and the issue may happen in other test files too. So, I thought a workaround is better than pending tests. Note the commit openssl/openssl@2acb0d3 is the essential fix for this issue.I believe that the idea is simple. Manually try non-zero selections
EVP_PKEY_KEY_PARAMETERS
,EVP_PKEY_PUBLIC_KEY
andEVP_PKEY_KEYPAIR
in order, instead of specifying selection0
(pick up whatever you can) option in the cases of the affected OpenSSL versions, and the provider number is more than equal 2. Because this issue can happen when a decoding provider is different from encrypt management provider.Here are some notes.
ossl_count_provider_number
function is the best. Please review it.selections
dynamically is the best way considering this repository or Ruby's coding style. Please let me know if there is a better way.Thanks.