Repository navigation
Use EVP_PKEY for RSA Decrypt - #50063
Conversation
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks Issue Details
Contributes to #46526
|
|
OK, I'm officially confused. |
|
@bartonjs Hmm. Let me give it a shot. |
| size_t written; | ||
|
|
||
| if (EVP_PKEY_decrypt(ctx, destination, &written, source, Int32ToSizeT(sourceLen)) > 0) |
There was a problem hiding this comment.
@bartonjs written needs to be initialized to the length of destination here. From OpenSSL docs:
If out is not NULL then before the call the outlen parameter should contain the length of the out buffer, if the call is successful the decrypted data is written to out and the amount of data written to outlen.
So written is an in/out, not just an out and might be garbage, which makes sense why all of the failures were in checked / release builds. OpenSSL then checks the that the outlen input is long enough to write to.
The validation call is here:
And if arglen (written in your case) is too small after checking it against the key size, it throws.
If you initialize written to zero first, the error will happen consistently, just to demonstrate that the value prior to calling EVP_PKEY_decrypt matters.
There was a problem hiding this comment.
I opened a PR into your PR for this here. bartonjs#1
If the PR into a PR is too weird or doesn't work you can grab a patch here and apply it directly to your branch https://github.com/bartonjs/runtime/pull/1.patch (assuming the changes are useful 😄 )
There was a problem hiding this comment.
Oy, what an embarrassing RTFM moment. Thanks for the detective work.
There was a problem hiding this comment.
I opened a PR into your PR for this here
Huh, the tab had gotten your first message, but not the second. I didn't ignore your PRPR, just happened to have made a pretty-darn-close-to-identical version before seeing that it existed (when catching up on email notifications).
There was a problem hiding this comment.
No worries. I'm glad we pretty much came to the same change set. 😀
|
The new failures aren't caused by the latest commit, going ahead and merging. |
EVP_DIGEST*/IntPtr cache from HashProviderDispenser to an Interop file so it can be shared across S.S.C.Algorithms and S.S.C.OpenSsl.Contributes to #46526