Skip to content

Commit ef3d8dd

Browse files
panvaUlisesGascon
authored andcommitted
crypto: remove webcrypto EdDSA key checks and properties
As per WICG/webcrypto-secure-curves#24 PR-URL: #49408 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 8949cc7 commit ef3d8dd

File tree

4 files changed

+17
-36
lines changed

4 files changed

+17
-36
lines changed

doc/api/webcrypto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ added: v15.0.0
16391639
The length (in bytes) of the random salt to use.
16401640

16411641
[^1]: An experimental implementation of
1642-
[Secure Curves in the Web Cryptography API][] as of 05 May 2022
1642+
[Secure Curves in the Web Cryptography API][] as of 30 August 2023
16431643

16441644
[JSON Web Key]: https://tools.ietf.org/html/rfc7517
16451645
[Key usages]: #cryptokeyusages

lib/internal/crypto/cfrg.js

-11
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,6 @@ async function cfrgImportKey(
272272
'DataError');
273273
}
274274

275-
if (keyData.alg !== undefined) {
276-
if (
277-
(name === 'Ed25519' || name === 'Ed448') &&
278-
keyData.alg !== 'EdDSA'
279-
) {
280-
throw lazyDOMException(
281-
'JWK "alg" does not match the requested algorithm',
282-
'DataError');
283-
}
284-
}
285-
286275
if (!isPublic && typeof keyData.x !== 'string') {
287276
throw lazyDOMException('Invalid JWK', 'DataError');
288277
}

lib/internal/crypto/webcrypto.js

-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ async function exportKeyJWK(key) {
475475
// Fall through
476476
case 'Ed448':
477477
jwk.crv ||= key.algorithm.name;
478-
jwk.alg = 'EdDSA';
479478
return jwk;
480479
case 'AES-CTR':
481480
// Fall through

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

+16-23
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,8 @@ async function testImportJwk({ name, publicUsages, privateUsages }, extractable)
251251
assert.strictEqual(pvtJwk.crv, jwk.crv);
252252
assert.strictEqual(pvtJwk.d, jwk.d);
253253

254-
if (jwk.crv.startsWith('Ed')) {
255-
assert.strictEqual(pubJwk.alg, 'EdDSA');
256-
assert.strictEqual(pvtJwk.alg, 'EdDSA');
257-
} else {
258-
assert.strictEqual(pubJwk.alg, undefined);
259-
assert.strictEqual(pvtJwk.alg, undefined);
260-
}
254+
assert.strictEqual(pubJwk.alg, undefined);
255+
assert.strictEqual(pvtJwk.alg, undefined);
261256
} else {
262257
await assert.rejects(
263258
subtle.exportKey('jwk', publicKey), {
@@ -281,24 +276,22 @@ async function testImportJwk({ name, publicUsages, privateUsages }, extractable)
281276
{ message: 'Invalid JWK "use" Parameter' });
282277
}
283278

279+
// The JWK alg member is ignored
280+
// https://github.com/WICG/webcrypto-secure-curves/pull/24
284281
if (name.startsWith('Ed')) {
285-
await assert.rejects(
286-
subtle.importKey(
287-
'jwk',
288-
{ kty: jwk.kty, x: jwk.x, crv: jwk.crv, alg: 'foo' },
289-
{ name },
290-
extractable,
291-
publicUsages),
292-
{ message: 'JWK "alg" does not match the requested algorithm' });
282+
await subtle.importKey(
283+
'jwk',
284+
{ kty: jwk.kty, x: jwk.x, crv: jwk.crv, alg: 'foo' },
285+
{ name },
286+
extractable,
287+
publicUsages);
293288

294-
await assert.rejects(
295-
subtle.importKey(
296-
'jwk',
297-
{ ...jwk, alg: 'foo' },
298-
{ name },
299-
extractable,
300-
privateUsages),
301-
{ message: 'JWK "alg" does not match the requested algorithm' });
289+
await subtle.importKey(
290+
'jwk',
291+
{ ...jwk, alg: 'foo' },
292+
{ name },
293+
extractable,
294+
privateUsages);
302295
}
303296

304297
for (const crv of [undefined, name === 'Ed25519' ? 'Ed448' : 'Ed25519']) {

0 commit comments

Comments
 (0)