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
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
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
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
327618c430
crypto: add SHAKE 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:56 +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
Filip Skokan
0cfc471e82
crypto: ensure expected JWK alg in SubtleCrypto.importKey RSA imports
...
PR-URL: https://github.com/nodejs/node/pull/57450
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2025-03-16 15:32:12 +00:00
Filip Skokan
d18f4878cf
src: refactor SubtleCrypto algorithm and length validations
...
PR-URL: https://github.com/nodejs/node/pull/57319
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-03-08 06:38:17 -08:00
Filip Skokan
6fdd4e6dcf
src: refactor SubtleCrypto algorithm and length validations
...
PR-URL: https://github.com/nodejs/node/pull/57273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
2025-03-04 17:45:51 +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
b64006c0ed
crypto: ensure invalid SubtleCrypto JWK data import results in DataError
...
PR-URL: https://github.com/nodejs/node/pull/55041
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2024-09-23 15:28:44 +00:00
Filip Skokan
2241e8c5b3
crypto: validate RSA-PSS saltLength in subtle.sign and subtle.verify
...
fixes: https://github.com/nodejs/node/issues/52188
PR-URL: https://github.com/nodejs/node/pull/52262
Fixes: https://github.com/nodejs/node/issues/52188
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
2024-04-03 05:16:10 +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
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
Filip Skokan
a6dd939ce8
crypto: refactor verify acceptable key usage functions
...
PR-URL: https://github.com/nodejs/node/pull/45569
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-11-26 14:41:28 +00:00
Filip Skokan
e73e89eedf
crypto: use DataError for webcrypto keyData import failures
...
PR-URL: https://github.com/nodejs/node/pull/45569
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-11-26 14:41:24 +00:00
Filip Skokan
73a5112583
crypto: handle more webcrypto errors with OperationError
...
PR-URL: https://github.com/nodejs/node/pull/45320
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-11-07 06:35:35 +00:00
Antoine du Hamel
eb32a8443a
lib: add lint rule to protect against Object.prototype.then pollution
...
PR-URL: https://github.com/nodejs/node/pull/45061
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-10-21 03:12:03 +00:00
Filip Skokan
0d80e7344e
crypto: add causes to applicable webcrypto's OperationError
...
PR-URL: https://github.com/nodejs/node/pull/44890
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-10-10 01:12:28 +00:00
Filip Skokan
ac1b90eed1
crypto: fix webcrypto operation errors to be OperationError
...
PR-URL: https://github.com/nodejs/node/pull/44171
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-08-12 19:29:14 +00:00
Filip Skokan
be03c09ab0
crypto: fix webcrypto RSA generateKey() use of publicExponent
...
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:32 +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
12af4319b5
crypto: align webcrypto RSA key import/export with other implementations
...
closes #39959
see https://github.com/w3c/webcrypto/issues/307
see https://github.com/w3c/webcrypto/pull/305
PR-URL: https://github.com/nodejs/node/pull/42816
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-05-25 15:31:14 +01:00
Filip Skokan
5d34ef509e
crypto: check webcrypto asymmetric key types during importKey
...
PR-URL: https://github.com/nodejs/node/pull/39962
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-09-07 18:25:39 +00:00
XadillaX
2de139b5d5
lib: make lazyDOMException more common
...
PR-URL: https://github.com/nodejs/node/pull/39105
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-06-28 13:44:28 +08:00
Filip Skokan
e8cb6446ef
crypto: reconcile oneshot sign/verify sync and async implementations
...
PR-URL: https://github.com/nodejs/node/pull/37816
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-04-08 10:08:26 +02:00
Filip Skokan
c81d0fa9bc
crypto: use correct webcrypto RSASSA-PKCS1-v1_5 algorithm name
...
PR-URL: https://github.com/nodejs/node/pull/38029
Refs: https://www.w3.org/TR/WebCryptoAPI/#rsassa-pkcs1
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-04-04 00:08:37 +02:00
Filip Skokan
25985d6522
crypto: add optional callback to crypto.sign and crypto.verify
...
PR-URL: https://github.com/nodejs/node/pull/37500
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-03-10 15:11:17 -08:00
Antoine du Hamel
75259c7492
crypto: refactor hasAnyNotIn to avoid unsafe array iteration
...
PR-URL: https://github.com/nodejs/node/pull/37433
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2021-02-26 16:34:04 +01:00
Antoine du Hamel
08a2383a5e
crypto: refactor to avoid unsafe array iteration
...
PR-URL: https://github.com/nodejs/node/pull/37364
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2021-02-19 12:55:54 +01:00
James M Snell
dae283d96f
crypto: refactoring internals, add WebCrypto
...
Fixes: https://github.com/nodejs/node/issues/678
Refs: https://github.com/nodejs/node/issues/26854
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/35093
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-10-07 17:27:05 -07:00