Filip Skokan
4cb1f28413
lib: improve Web Cryptography key validation ordering
...
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62749
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2026-04-17 07:47:49 +00:00
Ali Hassan
bee1087258
lib: reject SharedArrayBuffer in web APIs per spec
...
Signed-off-by: Ali Hassan <ali-hassan27@outlook.com >
PR-URL: https://github.com/nodejs/node/pull/62632
Refs: https://github.com/nodejs/node/issues/59688
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2026-04-16 19:53:24 +00:00
Filip Skokan
dfe438dc73
lib: cleanup stateless diffiehellman key handling
...
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62645
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-04-12 05:39:39 +00:00
Filip Skokan
e6ef4774c2
crypto: align key argument names in docs and error messages
...
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62527
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-04-09 08:10:14 +02:00
Filip Skokan
1b5dc9bbc5
crypto: accept key data in crypto.diffieHellman() and cleanup DH jobs
...
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62527
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-04-09 08:10:12 +02:00
nabeel378
dec597354b
crypto: implement randomUUIDv7()
...
Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62553
Fixes: https://github.com/nodejs/node/issues/62529
Refs: https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2026-04-05 10:12:21 +00:00
Filip Skokan
1ccae7cce4
crypto: unify asymmetric key import through KeyObjectHandle::Init
...
Consolidate all asymmetric key import paths (DER/PEM, JWK, raw) into
a single KeyObjectHandle::Init() entry point with a uniform signature.
Remove the per-type C++ init methods (InitECRaw, InitEDRaw, InitPqcRaw,
InitJwk, InitECPrivateRaw) and their JS-side callers, replacing them
with shared C++ and JS helpers.
createPublicKey, createPrivateKey, sign, verify, and other operations
that accept key material now handle JWK and raw formats directly in
C++, removing redundant JS-to-C++ key handle round-trips.
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62499
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-03-31 19:57:34 +00:00
Filip Skokan
c3042c605b
crypto: recognize raw formats in keygen
...
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62480
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-03-30 21:35:58 +02:00
Filip Skokan
adac077484
crypto: runtime-deprecate DEP0203 and DEP0204
...
PR-URL: https://github.com/nodejs/node/pull/62453
Refs: https://github.com/nodejs/node/issues/55293
Refs: https://github.com/nodejs/node/pull/62321
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2026-03-29 14:35:10 +00:00
Filip Skokan
e0cab9dcf7
crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms
...
PR-URL: https://github.com/nodejs/node/pull/62183
Refs: https://wicg.github.io/webcrypto-modern-algos/#kangarootwelve
Refs: https://wicg.github.io/webcrypto-modern-algos/#turboshake
Refs: https://www.rfc-editor.org/rfc/rfc9861.html
Refs: https://redirect.github.com/openssl/openssl/issues/30304
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2026-03-26 22:04:32 +01:00
Filip Skokan
d4fa60cf9f
crypto: add raw key formats support to the KeyObject APIs
...
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.
PR-URL: https://github.com/nodejs/node/pull/62240
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-03-26 10:31:26 +01:00
Filip Skokan
69fdff9d30
lib: make SubtleCrypto.supports enumerable
...
PR-URL: https://github.com/nodejs/node/pull/62307
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-03-20 07:57:46 +00:00
Filip Skokan
b328bf74bd
lib,src: implement QuotaExceededError as DOMException-derived interface
...
Implement QuotaExceededError as a DOMException-derived interface per the
WebIDL specification update.
QuotaExceededError is now a proper constructor exposed as a global
[Exposed=*] interface that extends DOMException with optional `quota`
and `requested` attributes (both nullable doubles, defaulting to null).
The constructor validates that quota and requested are finite,
non-negative, and that requested is not less than quota when both are
provided.
QuotaExceededError is [Serializable] and supports structuredClone,
preserving the quota and requested values across the serialization
boundary.
Callers updated:
- crypto.getRandomValues() now throws a QuotaExceededError instance
- WebStorage (C++) now constructs QuotaExceededError directly
Refs: https://redirect.github.com/whatwg/webidl/pull/1465
Fixes: https://github.com/nodejs/node/issues/58987
PR-URL: https://github.com/nodejs/node/pull/62293
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2026-03-19 14:41:50 +01:00
Filip Skokan
ab8dc2b84c
crypto: rename CShakeParams and KmacParams length to outputLength
...
PR-URL: https://github.com/nodejs/node/pull/61875
Refs: https://github.com/web-platform-tests/wpt/pull/57802
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2026-03-16 22:04:01 +01:00
Filip Skokan
3e5a2f0fa9
lib: prefer primordials in SubtleCrypto
...
PR-URL: https://github.com/nodejs/node/pull/62226
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com >
2026-03-14 12:52:22 +00:00
Filip Skokan
8ccbe8e384
crypto: reject ML-KEM/ML-DSA PKCS#8 import without seed in SubtleCrypto
...
Reject importing ML-KEM and ML-DSA PKCS#8 private keys that do not
include a seed, throwing NotSupportedError.
Also add tests for importing PKCS#8 keys with a mismatched expanded key.
Refs: https://redirect.github.com/WICG/webcrypto-modern-algos/pull/34
PR-URL: https://github.com/nodejs/node/pull/62218
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
2026-03-13 21:22:20 +00:00
Filip Skokan
aaa91515fc
crypto: refactor WebCrypto AEAD algorithms auth tag handling
...
PR-URL: https://github.com/nodejs/node/pull/62169
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2026-03-11 18:43:14 +00:00
Filip Skokan
e1ca754de0
crypto: read algorithm name property only once in normalizeAlgorithm
...
PR-URL: https://github.com/nodejs/node/pull/62170
Refs: https://redirect.github.com/web-platform-tests/wpt/pull/57614#pullrequestreview-3808145365
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2026-03-11 18:23:21 +00:00
Filip Skokan
d9f22269c0
crypto: add missing AES dictionaries
...
PR-URL: https://github.com/nodejs/node/pull/62099
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2026-03-06 10:39:52 +00:00
Filip Skokan
856231e8c4
crypto: fix importKey required argument count check
...
PR-URL: https://github.com/nodejs/node/pull/62099
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2026-03-06 10:39:51 +00:00
Antoine du Hamel
79df8b209b
lib,test: enforce use of assert.fail via a lint rule
...
PR-URL: https://github.com/nodejs/node/pull/61004
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2025-12-11 15:23:33 +01:00
Filip Skokan
94cd600542
crypto: fix DOMException name for non-extractable key error
...
PR-URL: https://github.com/nodejs/node/pull/60830
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-11-30 21:45:27 +00:00
Livia Medeiros
46dc5d7c9f
lib: prefer call() over apply() if argument list is not array
...
PR-URL: https://github.com/nodejs/node/pull/60796
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2025-11-23 08:45:46 +00:00
Filip Skokan
537df2eeb3
lib: refactor JWK import PQC support check
...
PR-URL: https://github.com/nodejs/node/pull/60586
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2025-11-13 21:45:28 +00:00
Filip Skokan
238899169f
crypto: ensure documented RSA-PSS saltLength default is used
...
PR-URL: https://github.com/nodejs/node/pull/60662
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-11-12 11:53:01 +00:00
James M Snell
ed94bc48f3
src: update crypto.getCipherInfo() to use DictionaryTemplate
...
Also, have it use a null prototype
PR-URL: https://github.com/nodejs/node/pull/60036
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2025-10-05 14:05:35 +00:00
Patrick Costa
64a8b4b1ba
crypto: expose signatureAlgorithm on X509Certificate
...
Adds the `signatureAlgorithm` property to a X509Certificate allowing
users to retrieve a string representing the algorithm used to sign the
certificate. This string is defined by the OpenSSL library.
Fixes: https://github.com/nodejs/node/issues/59103
PR-URL: https://github.com/nodejs/node/pull/59235
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2025-09-16 19:27:04 +00:00
Renegade334
8869210dd8
crypto: use return await when returning Promises from async functions
...
This offers _some_ resistance to `%Promise.prototype%` pollution.
Refs: https://github.com/nodejs/node/issues/59699
PR-URL: https://github.com/nodejs/node/pull/59841
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2025-09-12 14:21:50 +00:00
Renegade334
7a205d0ac0
crypto: use async functions for non-stub Promise-returning functions
...
These were intended to mimic simple async functions, but exceptions
thrown in the function body would be returned synchronously, not
wrapped in a rejected Promise.
PR-URL: https://github.com/nodejs/node/pull/59841
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2025-09-12 14:21:49 +00:00
Renegade334
33e3e423d9
crypto: avoid calls to promise.catch()
...
This avoids explicit calls to the user-mutable
`%Promise.prototype%.catch`, and by association, implicit calls to the
user-mutable `%Promise.prototype%.then`.
PR-URL: https://github.com/nodejs/node/pull/59841
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2025-09-12 14:21:49 +00:00
Filip Skokan
d6221f6f51
crypto: refactor subtle methods to use synchronous import
...
Refs: #59699
PR-URL: https://github.com/nodejs/node/pull/59771
Refs: https://github.com/nodejs/node/issues/59699
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-09-07 20:59:27 +00:00
Filip Skokan
a3cd430ef8
crypto: support Ed448 and ML-DSA context parameter in node:crypto
...
PR-URL: https://github.com/nodejs/node/pull/59570
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-09-07 13:17:42 +00:00
Filip Skokan
0124e0e0d7
crypto: support Ed448 and ML-DSA context parameter in Web Cryptography
...
PR-URL: https://github.com/nodejs/node/pull/59570
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-09-07 13:17:42 +00:00
Filip Skokan
6478dd0e28
lib: prefer TypedArrayPrototype primordials
...
Refs: #59699
PR-URL: https://github.com/nodejs/node/pull/59766
Refs: https://github.com/nodejs/node/issues/59699
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
2025-09-07 12:34:43 +00:00
Filip Skokan
14c68e3b53
crypto: add KMAC Web Cryptography algorithms
...
PR-URL: https://github.com/nodejs/node/pull/59647
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-09-06 22:43:15 +00:00
René
196f5466af
lib: revert to using default derived class constructors
...
PR-URL: https://github.com/nodejs/node/pull/59650
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-08-30 14:28:10 +00:00
Filip Skokan
27e2d81617
crypto: add Argon2 Web Cryptography algorithms
...
PR-URL: https://github.com/nodejs/node/pull/59544
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
2025-08-26 16:05:56 +00:00
Filip Skokan
d00228f5ca
crypto: support SLH-DSA KeyObject, sign, and verify
...
PR-URL: https://github.com/nodejs/node/pull/59537
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2025-08-26 15:41:25 +00:00
Filip Skokan
8692e601cc
crypto: add AES-OCB Web Cryptography algorithm
...
PR-URL: https://github.com/nodejs/node/pull/59539
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-08-24 09:47:20 +00:00
Filip Skokan
589ef79bf8
crypto: support ML-KEM in Web Cryptography
...
PR-URL: https://github.com/nodejs/node/pull/59569
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-08-23 17:01:51 +02:00
Filip Skokan
0fab11805f
crypto: require HMAC key length with SHA-3 hashes in Web Cryptography
...
PR-URL: https://github.com/nodejs/node/pull/59567
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2025-08-23 10:25:50 +00:00
Filip Skokan
7178e9141a
crypto: fix subtle.getPublicKey error for secret type key inputs
...
PR-URL: https://github.com/nodejs/node/pull/59558
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2025-08-22 15:56:56 +00:00
Filip Skokan
d30090b427
crypto: return cached copies from CryptoKey algorithm and usages getters
...
Fixes: https://github.com/nodejs/node/issues/59534
PR-URL: https://github.com/nodejs/node/pull/59538
Fixes: https://github.com/nodejs/node/issues/59535
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-08-21 14:14:57 +00:00
Filip Skokan
9d744b5b63
crypto: use CryptoKey internal slots in Web Cryptography
...
PR-URL: https://github.com/nodejs/node/pull/59538
Fixes: https://github.com/nodejs/node/issues/59535
Fixes: https://github.com/nodejs/node/issues/59534
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-08-21 14:14:57 +00:00
Filip Skokan
7a47cbf4c5
crypto: normalize RsaHashedKeyParams publicExponent
...
Fixes: https://github.com/nodejs/node/issues/59535
PR-URL: https://github.com/nodejs/node/pull/59538
Fixes: https://github.com/nodejs/node/issues/59534
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-08-21 14:14:56 +00:00
Filip Skokan
f8d68d30ae
crypto: support ML-KEM, DHKEM, and RSASVE key encapsulation mechanisms
...
PR-URL: https://github.com/nodejs/node/pull/59491
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-08-20 14:30:58 +00:00
bdcab711b8
crypto: add argon2() and argon2Sync() methods
...
Co-authored-by: Filip Skokan <panva.ip@gmail.com >
Co-authored-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/50353
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-08-19 19:30:38 +00:00
Filip Skokan
eaf1c15749
crypto: support ML-DSA spki/pkcs8 key formats in Web Cryptography
...
PR-URL: https://github.com/nodejs/node/pull/59365
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-08-19 15:57:27 +02:00
Filip Skokan
5329f73816
lib: refactor kSupportedAlgorithms
...
PR-URL: https://github.com/nodejs/node/pull/59365
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-08-19 15:57:25 +02:00
Filip Skokan
0cc2c83e32
crypto: subject some algorithms in Web Cryptography on BoringSSL absence
...
PR-URL: https://github.com/nodejs/node/pull/59365
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-08-19 15:57:23 +02:00