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 @@ -262,6 +262,35 @@ async function testImportJwk(
262262 }
263263}
264264
265+ async function testImportRaw ( { name, publicUsages } , namedCurve ) {
266+ const jwk = keyData [ namedCurve ] . jwk ;
267+
268+ const [ publicKey ] = await Promise . all ( [
269+ subtle . importKey (
270+ 'raw' ,
271+ Buffer . concat ( [
272+ Buffer . alloc ( 1 , 0x04 ) ,
273+ Buffer . from ( jwk . x , 'base64url' ) ,
274+ Buffer . from ( jwk . y , 'base64url' ) ,
275+ ] ) ,
276+ { name, namedCurve } ,
277+ true , publicUsages ) ,
278+ subtle . importKey (
279+ 'raw' ,
280+ Buffer . concat ( [
281+ Buffer . alloc ( 1 , 0x03 ) ,
282+ Buffer . from ( jwk . x , 'base64url' ) ,
283+ ] ) ,
284+ { name, namedCurve } ,
285+ true , publicUsages ) ,
286+ ] ) ;
287+
288+ assert . strictEqual ( publicKey . type , 'public' ) ;
289+ assert . deepStrictEqual ( publicKey . usages , publicUsages ) ;
290+ assert . strictEqual ( publicKey . algorithm . name , name ) ;
291+ assert . strictEqual ( publicKey . algorithm . namedCurve , namedCurve ) ;
292+ }
293+
265294( async function ( ) {
266295 const tests = [ ] ;
267296 testVectors . forEach ( ( vector ) => {
@@ -271,6 +300,7 @@ async function testImportJwk(
271300 tests . push ( testImportPkcs8 ( vector , namedCurve , extractable ) ) ;
272301 tests . push ( testImportJwk ( vector , namedCurve , extractable ) ) ;
273302 } ) ;
303+ tests . push ( testImportRaw ( vector , namedCurve ) ) ;
274304 } ) ;
275305 } ) ;
276306
You can’t perform that action at this time.
0 commit comments