Skip to content

Commit 920d8c5

Browse files
panvabengl
authored andcommitted
crypto: align webcrypto RSA key import/export with other implementations
closes #39959 see w3c/webcrypto#307 see w3c/webcrypto#305 PR-URL: #42816 Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent b187060 commit 920d8c5

File tree

3 files changed

+1
-90
lines changed

3 files changed

+1
-90
lines changed

lib/internal/crypto/rsa.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,7 @@ async function rsaImportKey(
326326
'NotSupportedError');
327327
}
328328

329-
if (algorithm.name === 'RSA-PSS') {
330-
if (
331-
keyObject.asymmetricKeyType !== 'rsa' &&
332-
keyObject.asymmetricKeyType !== 'rsa-pss'
333-
) {
334-
throw lazyDOMException('Invalid key type', 'DataError');
335-
}
336-
} else if (keyObject.asymmetricKeyType !== 'rsa') {
329+
if (keyObject.asymmetricKeyType !== 'rsa') {
337330
throw lazyDOMException('Invalid key type', 'DataError');
338331
}
339332

test/parallel/test-webcrypto-export-import-rsa.js

-42
Original file line numberDiff line numberDiff line change
@@ -481,48 +481,6 @@ const testVectors = [
481481
await Promise.all(variations);
482482
})().then(common.mustCall());
483483

484-
{
485-
const publicPem = fixtures.readKey('rsa_pss_public_2048.pem', 'ascii');
486-
const privatePem = fixtures.readKey('rsa_pss_private_2048.pem', 'ascii');
487-
488-
const publicDer = Buffer.from(
489-
publicPem.replace(
490-
/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,
491-
''
492-
),
493-
'base64'
494-
);
495-
const privateDer = Buffer.from(
496-
privatePem.replace(
497-
/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,
498-
''
499-
),
500-
'base64'
501-
);
502-
503-
(async () => {
504-
const key = await subtle.importKey(
505-
'spki',
506-
publicDer,
507-
{ name: 'RSA-PSS', hash: 'SHA-256' },
508-
true,
509-
['verify']);
510-
const jwk = await subtle.exportKey('jwk', key);
511-
assert.strictEqual(jwk.alg, 'PS256');
512-
})().then(common.mustCall());
513-
514-
(async () => {
515-
const key = await subtle.importKey(
516-
'pkcs8',
517-
privateDer,
518-
{ name: 'RSA-PSS', hash: 'SHA-256' },
519-
true,
520-
['sign']);
521-
const jwk = await subtle.exportKey('jwk', key);
522-
assert.strictEqual(jwk.alg, 'PS256');
523-
})().then(common.mustCall());
524-
}
525-
526484
{
527485
const ecPublic = crypto.createPublicKey(
528486
fixtures.readKey('ec_p256_public.pem'));

test/parallel/test-webcrypto-rsa-pss-params.js

-40
This file was deleted.

0 commit comments

Comments
 (0)