| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,13 +72,6 @@ function verifyAcceptableCfrgKeyUse(name, type, usages) { | |||
| 72 | 72 | } | |
| 73 | 73 | } | |
| 74 | 74 | ||
| 75 | - function createECPublicKeyRaw(name, keyData) { | ||
| 76 | - const handle = new KeyObjectHandle(); | ||
| 77 | - keyData = getArrayBufferOrView(keyData, 'keyData'); | ||
| 78 | - if (handle.initECRaw(name.toLowerCase(), keyData)) | ||
| 79 | - return new PublicKeyObject(handle); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | 75 | function createCFRGRawKey(name, keyData, isPublic) { | |
| 83 | 76 | const handle = new KeyObjectHandle(); | |
| 84 | 77 | keyData = getArrayBufferOrView(keyData, 'keyData'); | |
@@ -297,7 +290,7 @@ async function cfrgImportKey( | |||
| 297 | 290 | } | |
| 298 | 291 | case 'raw': { | |
| 299 | 292 | verifyAcceptableCfrgKeyUse(name, 'public', usagesSet); | |
| 300 | - keyObject = createECPublicKeyRaw(name, keyData); | ||
| 293 | + keyObject = createCFRGRawKey(name, keyData, true); | ||
| 301 | 294 | if (keyObject === undefined) | |
| 302 | 295 | throw lazyDOMException('Unable to import CFRG key', 'OperationError'); | |
| 303 | 296 | break; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,6 +281,20 @@ async function testImportJwk({ name, publicUsages, privateUsages }, extractable) | |||
| 281 | 281 | } | |
| 282 | 282 | } | |
| 283 | 283 | ||
| 284 | + async function testImportRaw({ name, publicUsages }) { | ||
| 285 | + const jwk = keyData[name].jwk; | ||
| 286 | + | ||
| 287 | + const publicKey = await subtle.importKey( | ||
| 288 | + 'raw', | ||
| 289 | + Buffer.from(jwk.x, 'base64url'), | ||
| 290 | + { name }, | ||
| 291 | + true, publicUsages); | ||
| 292 | + | ||
| 293 | + assert.strictEqual(publicKey.type, 'public'); | ||
| 294 | + assert.deepStrictEqual(publicKey.usages, publicUsages); | ||
| 295 | + assert.strictEqual(publicKey.algorithm.name, name); | ||
| 296 | + } | ||
| 297 | + | ||
| 284 | 298 | (async function() { | |
| 285 | 299 | const tests = []; | |
| 286 | 300 | testVectors.forEach((vector) => { | |
@@ -289,6 +303,7 @@ async function testImportJwk({ name, publicUsages, privateUsages }, extractable) | |||
| 289 | 303 | tests.push(testImportPkcs8(vector, extractable)); | |
| 290 | 304 | tests.push(testImportJwk(vector, extractable)); | |
| 291 | 305 | }); | |
| 306 | + tests.push(testImportRaw(vector)); | ||
| 292 | 307 | }); | |
| 293 | 308 | ||
| 294 | 309 | await Promise.all(tests); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments