Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7f02e22

Browse filesBrowse files
panvadanielleadams
authored andcommitted
crypto: test webcrypto ec raw public key import
PR-URL: #43405 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 0a075cb commit 7f02e22
Copy full SHA for 7f02e22

File tree

Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-webcrypto-export-import-ec.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-export-import-ec.js
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.