crypto: add raw key formats support to the KeyObject APIs#62240
crypto: add raw key formats support to the KeyObject APIs#62240panva wants to merge 2 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
|
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62240 +/- ##
=======================================
Coverage 89.66% 89.67%
=======================================
Files 676 676
Lines 206500 206515 +15
Branches 39539 39582 +43
=======================================
+ Hits 185168 185198 +30
+ Misses 13463 13450 -13
+ Partials 7869 7867 -2
🚀 New features to boost your workflow:
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Add raw key format support (raw-public, raw-private, raw-seed) to KeyObject.prototype.export(), crypto.createPrivateKey(), and crypto.createPublicKey() for applicable asymmetric keys (EC, CFRG curves, ML-DSA, ML-KEM, and SLH-DSA). Also wire these to the Web Cryptography APIs and remove the unnecessary KeyExportJob. The KeyExportJob classes were removed because the export operations they performed are not computationally expensive. They're just serialization of already-available key data (SPKI, PKCS8, raw bytes). Running them as async CryptoJobs on the libuv thread pool added unnecessary overhead and complexity for operations that complete instantly.
|
cc @ChALkeR @paulmillr FYI as it makes working with ECC much much easier |
|
Great improvement! |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Yes, this is great, thanks! (I did not review the impl though) |
|
@ChALkeR doing so would go a long way to be able to land this with more confidence. |
notable-changePRs with changes that should be highlighted in changelogs.
👇
Add raw key format support (raw-public, raw-private, raw-seed) to KeyObject.prototype.export(), crypto.createPrivateKey(), and crypto.createPublicKey() for applicable asymmetric keys (EC, CFRG curves, ML-DSA, ML-KEM, and SLH-DSA). This intrinsically means it is supported as input to the other cryptographic APIs as well.
This also adds a much needed docs section on the different key formats and their usage examples.
Also wire these to their existing Web Cryptography APIs counterparts and remove the unnecessary KeyExportJob. The KeyExportJob classes were removed because the export operations they performed are not computationally expensive. They're just serialization of already-available key data (SPKI, PKCS8, raw bytes). Running them as async CryptoJobs on the libuv thread pool added unnecessary overhead and complexity for operations that complete instantly.
This is not a semver-major but bits of it depend on #62178 which is. I will try to open a partial backport to 25/24.
Key Type vs Format matrix
'pem''der''jwk''raw-public''raw-private''raw-seed''dh''dsa''ec''ed25519''ed448''ml-dsa-44''ml-dsa-65''ml-dsa-87''ml-kem-512''ml-kem-768''ml-kem-1024''rsa-pss''rsa''slh-dsa-sha2-128f''slh-dsa-sha2-128s''slh-dsa-sha2-192f''slh-dsa-sha2-192s''slh-dsa-sha2-256f''slh-dsa-sha2-256s''slh-dsa-shake-128f''slh-dsa-shake-128s''slh-dsa-shake-192f''slh-dsa-shake-192s''slh-dsa-shake-256f''slh-dsa-shake-256s''x25519''x448'