Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f82a804
crypto: use internal random buffer bounds
panva Sep 22, 2026
1cbd118
crypto: match algorithm names as ASCII
panva Sep 22, 2026
131cc41
crypto: reject short AES-KW inputs
panva Sep 22, 2026
0e286f0
crypto: isolate cipher job errors
panva Sep 22, 2026
5d64d76
crypto: convert getRandomValues views
panva Sep 22, 2026
bd27c23
crypto: validate normalized hash names
panva Sep 22, 2026
7129683
crypto: allow short AES-GCM IVs
panva Sep 22, 2026
3d8975b
crypto: allow unbound SubtleCrypto.supports
panva Sep 22, 2026
7f417a0
crypto: resolve supports overloads by type
panva Sep 22, 2026
9b6c75e
crypto: copy detached parameters as empty
panva Sep 22, 2026
a45414a
crypto: convert importKey data as a union
panva Sep 22, 2026
677404d
crypto: copy parameters without array species
panva Sep 22, 2026
4f7f16f
crypto: check RSA JWK alg with SHA-3 hashes
panva Sep 22, 2026
191d52a
crypto: reject duplicate unknown key usages
panva Sep 22, 2026
2ae6b20
crypto: handle PBKDF2 iteration limits
panva Sep 22, 2026
e937421
crypto: separate conversion from validation
panva Sep 22, 2026
36bb4f6
crypto: copy derived bits without species
panva Sep 22, 2026
716fc4e
crypto: minimize RSA public exponent metadata
panva Sep 22, 2026
02d6adf
crypto: create key usage arrays without species
panva Sep 22, 2026
6e9984c
crypto: derive Argon2 without worker threads
panva Sep 22, 2026
baaf5fc
crypto: report actual RSA modulus lengths
panva Sep 22, 2026
ac0931c
crypto: split hybrid keys without species
panva Sep 22, 2026
a95665b
crypto: use the public CryptoKey prototype
panva Sep 22, 2026
3e45b42
crypto: include EC public keys in PKCS8 exports
panva Sep 22, 2026
1f701b0
crypto: map JWK export failures to OperationError
panva Sep 22, 2026
36d932d
crypto: check EC coordinate conversion results
panva Sep 22, 2026
4a5c46f
benchmark: cover Web Crypto conversion costs
panva Sep 23, 2026
a216416
crypto: use backend cSHAKE and KMAC
panva Sep 23, 2026
4f26a35
crypto: verify empty KMAC outputs
panva Sep 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
crypto: check RSA JWK alg with SHA-3 hashes
Reject a supplied JWK alg when no matching identifier exists for the
requested RSA algorithm and hash.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
  • Loading branch information
panva committed Sep 24, 2026
commit 4f7f16fb8c026ba7c7645f6b0034d5c800b45110
2 changes: 1 addition & 1 deletion lib/internal/crypto/rsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function rsaImportKey(
algorithm.name === 'RSA-PSS' ? normalizeHashName.kContextJwkRsaPss :
normalizeHashName.kContextJwkRsaOaep);

if (expected && keyData.alg !== expected)
if (keyData.alg !== expected)
throw lazyDOMException(
'JWK "alg" does not match the requested algorithm',
'DataError');
Expand Down
42 changes: 42 additions & 0 deletions test/parallel/test-webcrypto-rsa-jwk-sha3-alg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const { isBoringSSL } = require('../common/crypto');
if (isBoringSSL)
common.skip('missing SHA-3');

const assert = require('assert');
const { createPrivateKey, createPublicKey } = require('crypto');
const fixtures = require('../common/fixtures');
const { subtle } = globalThis.crypto;

(async () => {
const privateKey = createPrivateKey(fixtures.readKey('rsa_private_2048.pem'));
const privateJwk = privateKey.export({ format: 'jwk' });
const publicJwk = createPublicKey(privateKey).export({ format: 'jwk' });

for (const name of ['RSA-PSS', 'RSASSA-PKCS1-v1_5', 'RSA-OAEP']) {
for (const hash of ['SHA3-256', 'SHA3-384', 'SHA3-512']) {
for (const jwk of [publicJwk, privateJwk]) {
const usages = name === 'RSA-OAEP' ? [jwk.d ? 'decrypt' : 'encrypt'] :
[jwk.d ? 'sign' : 'verify'];
const algorithm = { name, hash };
// There is no JWK alg identifier for RSA with SHA-3. Omitting alg is
// valid, but an identifier for SHA-2 or an unknown identifier is not.
const key = await subtle.importKey('jwk', jwk, algorithm, true, usages);
const exported = await subtle.exportKey('jwk', key);
assert.strictEqual(Object.hasOwn(exported, 'alg'), false);
const imported = await subtle.importKey('jwk', exported, algorithm, true, usages);
assert.deepStrictEqual(imported.algorithm, key.algorithm);
assert.deepStrictEqual(await subtle.exportKey('jwk', imported), exported);
for (const alg of ['RS256', 'PS256', 'RSA-OAEP-256', 'unknown']) {
await assert.rejects(subtle.importKey(
'jwk', { ...jwk, alg }, algorithm, true, usages), { name: 'DataError' });
}
}
}
}
})().then(common.mustCall());