File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,35 @@ async function testImportJwk(
282
282
}
283
283
}
284
284
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
+
285
314
( async function ( ) {
286
315
const tests = [ ] ;
287
316
testVectors . forEach ( ( vector ) => {
@@ -291,6 +320,7 @@ async function testImportJwk(
291
320
tests . push ( testImportPkcs8 ( vector , namedCurve , extractable ) ) ;
292
321
tests . push ( testImportJwk ( vector , namedCurve , extractable ) ) ;
293
322
} ) ;
323
+ tests . push ( testImportRaw ( vector , namedCurve ) ) ;
294
324
} ) ;
295
325
} ) ;
296
326
You can’t perform that action at this time.
0 commit comments