Skip to content

Commit 934077a

Browse files
panvatargos
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 <[email protected]>
1 parent 3674542 commit 934077a

File tree

3 files changed

+1
-90
lines changed

3 files changed

+1
-90
lines changed

‎lib/internal/crypto/rsa.js‎

Lines changed: 1 addition & 8 deletions
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-
throwlazyDOMException('Invalid key type','DataError');
335-
}
336-
}elseif(keyObject.asymmetricKeyType!=='rsa'){
329+
if(keyObject.asymmetricKeyType!=='rsa'){
337330
throwlazyDOMException('Invalid key type','DataError');
338331
}
339332

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -481,48 +481,6 @@ const testVectors = [
481481
awaitPromise.all(variations);
482482
})().then(common.mustCall());
483483

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

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

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
(0)