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 e28ea89

Browse filesBrowse files
panvadanielleadams
authored andcommitted
crypto: fix subtle.importKey JWK OKP public key import
PR-URL: #37255 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 85bed2e commit e28ea89
Copy full SHA for e28ea89

File tree

Expand file treeCollapse file tree

2 files changed

+34
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+34
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/crypto/ec.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/ec.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ async function ecImportKey(
303303
keyObject = createECRawKey(
304304
namedCurve,
305305
Buffer.from(
306-
isPublic ? keyData.k : keyData.d,
306+
isPublic ? keyData.x : keyData.d,
307307
'base64'),
308308
isPublic);
309309
break;
Collapse file

‎test/parallel/test-webcrypto-x25519-x448.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-x25519-x448.js
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,36 @@ assert.rejects(
244244
{
245245
message: /Unsupported named curves for ECDH/
246246
});
247+
248+
{
249+
// Private JWK import
250+
subtle.importKey(
251+
'jwk',
252+
{
253+
crv: 'X25519',
254+
d: '8CE-XY7cvbR-Pu7mILHq8YZ4hLGAA2-RD01he5q2wUA',
255+
x: '42IbTo34ZYANub5o42547vB6OxdEd44ztwZewoRch0Q',
256+
kty: 'OKP'
257+
},
258+
{
259+
name: 'ECDH',
260+
namedCurve: 'NODE-X25519'
261+
},
262+
true,
263+
['deriveBits']).then(common.mustCall());
264+
265+
// Public JWK import
266+
subtle.importKey(
267+
'jwk',
268+
{
269+
crv: 'X25519',
270+
x: '42IbTo34ZYANub5o42547vB6OxdEd44ztwZewoRch0Q',
271+
kty: 'OKP'
272+
},
273+
{
274+
name: 'ECDH',
275+
namedCurve: 'NODE-X25519'
276+
},
277+
true,
278+
[]).then(common.mustCall());
279+
}

0 commit comments

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