@@ -262,6 +262,35 @@ async function testImportJwk(
262
262
}
263
263
}
264
264
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
+
265
294
( async function ( ) {
266
295
const tests = [ ] ;
267
296
testVectors . forEach ( ( vector ) => {
@@ -271,6 +300,7 @@ async function testImportJwk(
271
300
tests . push ( testImportPkcs8 ( vector , namedCurve , extractable ) ) ;
272
301
tests . push ( testImportJwk ( vector , namedCurve , extractable ) ) ;
273
302
} ) ;
303
+ tests . push ( testImportRaw ( vector , namedCurve ) ) ;
274
304
} ) ;
275
305
} ) ;
276
306
0 commit comments