-
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
Faulty export for RSA-PSS public keys from node:crypto to webcrypto #49141
Comments
The webcrypto specification (live editor's draft at https://w3c.github.io/webcrypto/) no longer supports alternative OIDs on the account of their support never being properly implemented by implementors. Relevant PR on webcrypto's spec w3c/webcrypto#325 In other words, the crypto export is not faulty but the webcrypto import intentionally rejects the key material because RSA-PSS OID keys were ONLY supported by Node.js (but not correctly wrt roundtrip export/import), Deno and partially (but not correctly checking parameters) in Gecko tye specification (and our implementation) was updated to reflect the actual observable interoperable behaviour which is to not support the non-generic OIDs such as RSA-PSS, RSA-OAEP, and others. |
@panva do I interpret that correctly as "wontfix, working as intended"? |
@panva and how then I should export RSA-PSS public keys to be imported/used by browser? How I should test this kind of export-import with |
@bnoordhuis correct, this is wontfix working as intended. @koteisaev the webcrypto algorithm identifiers and node crypto keygen identifiers do not map to the same key material OIDs. I also talked about OIDs in my previous comment, not algorithms. You can certainly use plain old generic rsaEncryption key material for signing and verifying RSA-PSS signatures with both webcrypto and node crypto. |
@panva Thanks for clarification.
|
Version
18.17.1
Platform
Microsoft Windows NT 10.0.22621.0 x64
Subsystem
node:crypto
What steps will reproduce the bug?
RSA-PSS key generation
The
saltLength
in parameters type definition somehow isstring
so had to use theas any
trick here. But it seems does not affect the problem.public key exporting code
Import code in "browser emulator" with webcrypto
How often does it reproduce? Is there a required condition?
It always reproduced, and checked by other person I don't know.
What is the expected behavior? Why is that the expected behavior?
Expected behavior is exporting a RSA-PSS public key as RSA-PSS SPKI DER by
PublicKeyobject.export
that it can be successfully imported with the webcrypto.What do you see instead?
Instead i see the following error on
importKey
call:Additional information
I asked this question at StackOverflow: https://stackoverflow.com/questions/76891595/domexception-invalid-key-type-from-webcrypto-importkey-on-rsa-pss-public-key-in?noredirect=1#comment135553831_76891595
I got following comment: https://stackoverflow.com/questions/76891595/domexception-invalid-key-type-from-webcrypto-importkey-on-rsa-pss-public-key-in?noredirect=1#comment135553831_76891595
Providing it here as hope it will make this bug report more helpful.
The text was updated successfully, but these errors were encountered: