File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,35 @@ async function testImportJwk(
282282 }
283283}
284284
285+ async function testImportRaw ( { name, publicUsages } , namedCurve ) {
286+ const jwk = keyData [ namedCurve ] . jwk ;
287+
288+ const [ publicKey ] = await Promise . all ( [
289+ subtle . importKey (
290+ 'raw' ,
291+ Buffer . concat ( [
292+ Buffer . alloc ( 1 , 0x04 ) ,
293+ Buffer . from ( jwk . x , 'base64url' ) ,
294+ Buffer . from ( jwk . y , 'base64url' ) ,
295+ ] ) ,
296+ { name, namedCurve } ,
297+ true , publicUsages ) ,
298+ subtle . importKey (
299+ 'raw' ,
300+ Buffer . concat ( [
301+ Buffer . alloc ( 1 , 0x03 ) ,
302+ Buffer . from ( jwk . x , 'base64url' ) ,
303+ ] ) ,
304+ { name, namedCurve } ,
305+ true , publicUsages ) ,
306+ ] ) ;
307+
308+ assert . strictEqual ( publicKey . type , 'public' ) ;
309+ assert . deepStrictEqual ( publicKey . usages , publicUsages ) ;
310+ assert . strictEqual ( publicKey . algorithm . name , name ) ;
311+ assert . strictEqual ( publicKey . algorithm . namedCurve , namedCurve ) ;
312+ }
313+
285314( async function ( ) {
286315 const tests = [ ] ;
287316 testVectors . forEach ( ( vector ) => {
@@ -291,6 +320,7 @@ async function testImportJwk(
291320 tests . push ( testImportPkcs8 ( vector , namedCurve , extractable ) ) ;
292321 tests . push ( testImportJwk ( vector , namedCurve , extractable ) ) ;
293322 } ) ;
323+ tests . push ( testImportRaw ( vector , namedCurve ) ) ;
294324 } ) ;
295325 } ) ;
296326
You can’t perform that action at this time.
0 commit comments