File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -308,8 +308,20 @@ async function ecImportKey(
308308 case 'OKP' : {
309309 checkNamedCurve = false ;
310310 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+ }
313325
314326 if ( algorithm . name !== type )
315327 throw lazyDOMException ( 'Invalid algorithm name.' , 'DataError' ) ;
Original file line number Diff line number Diff line change @@ -264,7 +264,7 @@ assert.rejects(
264264 namedCurve : 'NODE-X25519'
265265 } ,
266266 true ,
267- [ 'deriveBits' ] ) . then ( common . mustCall ( ) ) ;
267+ [ 'deriveBits' ] ) . then ( common . mustCall ( ) , common . mustNotCall ( ) ) ;
268268
269269 // Public JWK import
270270 subtle . importKey (
@@ -279,7 +279,7 @@ assert.rejects(
279279 namedCurve : 'NODE-X25519'
280280 } ,
281281 true ,
282- [ ] ) . then ( common . mustCall ( ) ) ;
282+ [ ] ) . then ( common . mustCall ( ) , common . mustNotCall ( ) ) ;
283283
284284 for ( const asymmetricKeyType of [ 'x25519' , 'x448' ] ) {
285285 const { publicKey, privateKey } = generateKeyPairSync ( asymmetricKeyType ) ;
You can’t perform that action at this time.
0 commit comments