Skip to content

Commit ea4d94e

Browse files
committed
crypto: remove webcrypto EdDSA key checks and properties
As per WICG/webcrypto-secure-curves#24
1 parent fcf5de0 commit ea4d94e

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

lib/internal/crypto/cfrg.js

Lines changed: 0 additions & 11 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 7 additions & 13 deletions
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,23 @@ async function testImportJwk({ name, publicUsages, privateUsages }, extractable)
281276
{ message: 'Invalid JWK "use" Parameter' });
282277
}
283278

279+
// https://github.com/WICG/webcrypto-secure-curves/pull/24
284280
if (name.startsWith('Ed')) {
285-
await assert.rejects(
281+
await assert.doesNotReject(
286282
subtle.importKey(
287283
'jwk',
288284
{ kty: jwk.kty, x: jwk.x, crv: jwk.crv, alg: 'foo' },
289285
{ name },
290286
extractable,
291-
publicUsages),
292-
{ message: 'JWK "alg" does not match the requested algorithm' });
287+
publicUsages));
293288

294-
await assert.rejects(
289+
await assert.doesNotReject(
295290
subtle.importKey(
296291
'jwk',
297292
{ ...jwk, alg: 'foo' },
298293
{ name },
299294
extractable,
300-
privateUsages),
301-
{ message: 'JWK "alg" does not match the requested algorithm' });
295+
privateUsages));
302296
}
303297

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

0 commit comments

Comments
 (0)