File tree 2 files changed +16
-4
lines changed
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -308,8 +308,20 @@ async function ecImportKey(
308
308
case 'OKP' : {
309
309
checkNamedCurve = false ;
310
310
const isPublic = keyData . d === undefined ;
311
- const type = namedCurve === 'NODE-ED25519' || 'NODE-ED448' ?
312
- `NODE-${ keyData . crv . toUpperCase ( ) } ` : 'ECDH' ;
311
+
312
+ let type ;
313
+ switch ( namedCurve ) {
314
+ case 'NODE-ED25519' :
315
+ // Fall through
316
+ case 'NODE-ED448' :
317
+ type = `NODE-${ keyData . crv . toUpperCase ( ) } ` ;
318
+ break ;
319
+ case 'NODE-X25519' :
320
+ // Fall through
321
+ case 'NODE-X448' :
322
+ type = 'ECDH' ;
323
+ break ;
324
+ }
313
325
314
326
if ( algorithm . name !== type )
315
327
throw lazyDOMException ( 'Invalid algorithm name.' , 'DataError' ) ;
Original file line number Diff line number Diff line change @@ -264,7 +264,7 @@ assert.rejects(
264
264
namedCurve : 'NODE-X25519'
265
265
} ,
266
266
true ,
267
- [ 'deriveBits' ] ) . then ( common . mustCall ( ) ) ;
267
+ [ 'deriveBits' ] ) . then ( common . mustCall ( ) , common . mustNotCall ( ) ) ;
268
268
269
269
// Public JWK import
270
270
subtle . importKey (
@@ -279,7 +279,7 @@ assert.rejects(
279
279
namedCurve : 'NODE-X25519'
280
280
} ,
281
281
true ,
282
- [ ] ) . then ( common . mustCall ( ) ) ;
282
+ [ ] ) . then ( common . mustCall ( ) , common . mustNotCall ( ) ) ;
283
283
284
284
for ( const asymmetricKeyType of [ 'x25519' , 'x448' ] ) {
285
285
const { publicKey, privateKey } = generateKeyPairSync ( asymmetricKeyType ) ;
You can’t perform that action at this time.
0 commit comments