-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
node:crypto RSA-PSS seems to be broken #52188
Comments
I can reproduce the abort, probably something we can add validations for. The reason is that the You're asking for 512 bytes, maximum possible salt length is signature length - digest output length - 2 in bytes, so for your setup > 512 - 64 - 2 > 446. I assume you intended to have |
There's even a TODO from @jasnell to add this validation node/lib/internal/crypto/rsa.js Lines 313 to 316 in 511be6c
|
Thank you for a response. You are absolutely correct about my intention to use hash size as a salt length. And special thanks for pointing that
as it helped me do discover my forgiveness (I've forgot to ignore modulusLength argument that will be made unneccessary during refactoring). As to published fix, I have two suggestions.. At first, in my opinion, exception message shall point measurement units; most of cryptographic parameters are expressed in terms of bits (e.g. key sizes), but salt length gets measured in terms of bytes, hence message pointing valid length range may be misinterpreted. Another suggestion relates to types definitions. There are no comments at all; it would be nice to see these - in the same project I am using TypeORM providing those. P.S. Irrespective of my suggestions, I think issue shall be closed - uncaught exception is much better that server process termination. |
Version
v21.6.2
Platform
Linux host 6.6.19-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri Mar 1 18:16:16 UTC 2024 x86_64 GNU/Linux
Subsystem
node:crypto
What steps will reproduce the bug?
I was experimenting with digital signatures and found that RSA-PSS signatures does not work as expected. I was running jest tests during my experiments and got stuck in a message saying:
Efficiently, i was running test containing following lines:
And "~/core/crypto.ts" contain effectiely (excluding lot of commented-out lines):
As a result of such launch I see following in a terminal emulator window:
How often does it reproduce? Is there a required condition?
At my host and project is reproduces constantly
What is the expected behavior? Why is that the expected behavior?
Expected behavior is to see a message that signature has been created. Why? Just because it has been asked to do that.
What do you see instead?
As it was pointer above, I see an error message. And, also notification that core has been dumped.
Again, following message is diplayed (entire output of a run you'll find above):
Additional information
No response
The text was updated successfully, but these errors were encountered: