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
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
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
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
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
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
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
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
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
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
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
84aaed7597
crypto: add ChaCha20-Poly1305 Web Cryptography algorithm
...
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:08 +02:00
Filip Skokan
f4741ef8df
crypto: add subtle.getPublicKey() utility function 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:55:58 +02:00
Filip Skokan
1c4d534b75
crypto: add SHA-3 Web Cryptography digest algorithms
...
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:55:57 +02:00
Filip Skokan
90ec54345d
crypto: add SubtleCrypto.supports feature detection 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:55:54 +02:00
Filip Skokan
87f4f99c09
crypto: support ML-DSA 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:55:53 +02:00
Filip Skokan
700a965dc3
crypto: prepare webcrypto key import/export for modern algorithms
...
PR-URL: https://github.com/nodejs/node/pull/59284
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-08-05 13:25:29 +00:00
Node.js GitHub Bot
599ec77679
test: update WPT for WebCryptoAPI to edd42c005c
...
PR-URL: https://github.com/nodejs/node/pull/57365
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jason Zhang <xzha4350@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2025-03-09 18:44:18 +00:00
Filip Skokan
90e3e5e173
crypto: add KeyObject.prototype.toCryptoKey
...
PR-URL: https://github.com/nodejs/node/pull/55262
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2024-10-06 18:09:02 +00:00
Filip Skokan
d65b17082b
crypto: make deriveBits length parameter optional and nullable
...
PR-URL: https://github.com/nodejs/node/pull/53601
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-06-28 22:21:29 +00:00
Filip Skokan
a30ae50860
cli: remove --no-experimental-global-webcrypto flag
...
PR-URL: https://github.com/nodejs/node/pull/52564
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-04-19 13:02:01 +00:00
Filip Skokan
457cedda9d
crypto: remove webcrypto EdDSA key checks and properties
...
As per https://github.com/WICG/webcrypto-secure-curves/pull/24
PR-URL: https://github.com/nodejs/node/pull/49408
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2023-09-01 12:00:16 +00:00
Filip Skokan
71eda57ba3
crypto: fix webcrypto private/secret import with empty usages
...
Refs: #47864
PR-URL: https://github.com/nodejs/node/pull/47877
Refs: https://github.com/nodejs/node/issues/47864
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-05-07 10:54:28 +00:00
Antoine du Hamel
ab8942848b
lib: enforce use of trailing commas
...
PR-URL: https://github.com/nodejs/node/pull/46881
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2023-03-06 10:44:14 +01:00
Filip Skokan
4c1a27716b
crypto: re-add padding for AES-KW wrapped JWKs
...
PR-URL: https://github.com/nodejs/node/pull/46563
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-02-17 13:11:43 +00:00
Filip Skokan
3ef38c4bd7
crypto: use WebIDL converters in WebCryptoAPI
...
WebCryptoAPI functions' arguments are now coersed and validated as per
their WebIDL definitions like in other Web Crypto API implementations.
This further improves interoperability with other implementations of
Web Crypto API.
PR-URL: https://github.com/nodejs/node/pull/46067
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2023-01-17 08:57:58 +00:00
Antoine du Hamel
bb908fc886
crypto: simplify lazy loading of internal modules
...
The internal `require()` is actually just one map load (to see if the
module is already loaded) + one property load (state check for circular
dependencies) for modules that are already loaded.
Refs: https://github.com/nodejs/node/pull/45659#discussion_r1033762328
PR-URL: https://github.com/nodejs/node/pull/45809
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2022-12-12 15:17:44 +00:00
Filip Skokan
214354fc9f
crypto: fix webcrypto HMAC "get key length" in deriveKey and generateKey
...
PR-URL: https://github.com/nodejs/node/pull/44917
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-10-12 19:18:38 +00:00
Filip Skokan
eeec3eb16a
crypto: simplify webcrypto ECDH deriveBits
...
PR-URL: https://github.com/nodejs/node/pull/44946
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2022-10-12 18:38:20 +00:00
Antoine du Hamel
2849283c4c
crypto: remove non-standard webcrypto.Crypto.prototype.CryptoKey
...
`CryptoKey` is already available on the global object.
PR-URL: https://github.com/nodejs/node/pull/42083
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2022-09-17 15:54:36 +02:00
Filip Skokan
159b4d7a94
crypto: allow zero-length IKM in HKDF and in webcrypto PBKDF2
...
PR-URL: https://github.com/nodejs/node/pull/44201
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-08-12 21:36:29 +02:00
Filip Skokan
84db3e7b06
crypto: handle webcrypto generateKey() usages edge case
...
PR-URL: https://github.com/nodejs/node/pull/43454
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-06-25 06:22:35 +01:00
Filip Skokan
677bd668b7
crypto: fix webcrypto generateKey() with empty usages
...
PR-URL: https://github.com/nodejs/node/pull/43431
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-06-16 22:00:34 +02:00
Filip Skokan
fbfb91ba33
crypto: remove Node.js-specific webcrypto extensions
...
PR-URL: https://github.com/nodejs/node/pull/43310
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-06-11 08:04:20 +01:00
Filip Skokan
7e5da97d15
crypto: add CFRG curves to Web Crypto API
...
PR-URL: https://github.com/nodejs/node/pull/42507
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-06-04 07:20:27 +01:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
...
Refs: https://github.com/nodejs/node/pull/42921
PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2022-06-03 09:23:58 +01:00
Filip Skokan
603803ecb7
crypto: validate this in all webcrypto methods and getters
...
PR-URL: https://github.com/nodejs/node/pull/42815
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-04-23 18:42:45 +01:00
Filip Skokan
5d0eb10c80
crypto: do not add undefined hash in webcrypto normalizeAlgorithm
...
PR-URL: https://github.com/nodejs/node/pull/42559
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-04-03 11:11:21 +01:00
Filip Skokan
4fa6c89cd5
crypto: cleanup webcrypto jwk code
...
PR-URL: https://github.com/nodejs/node/pull/42562
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2022-04-03 11:11:02 +01:00
Filip Skokan
18bd02f245
crypto: fix webcrypto derive key lengths
...
PR-URL: https://github.com/nodejs/node/pull/42542
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-04-02 15:54:35 +01:00
Antoine du Hamel
6ee4228498
crypto: validate this value for webcrypto.getRandomValues
...
PR-URL: https://github.com/nodejs/node/pull/41760
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-02-26 17:12:48 +00:00
Antoine du Hamel
849991c6c4
crypto: expose Web Crypto API on the global scope
...
PR-URL: https://github.com/nodejs/node/pull/41938
Refs: https://developer.mozilla.org/en-US/docs/Web/API/crypto_property
Refs: https://github.com/nodejs/node/pull/41782
Refs: https://w3c.github.io/webcrypto
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2022-02-14 16:14:49 +00:00
Mestery
998e5acc69
lib: move kEnumerableProperty to internal/util
...
PR-URL: https://github.com/nodejs/node/pull/41877
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-02-11 17:30:47 +00:00