We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c62ed73 commit cf1e907Copy full SHA for cf1e907
lib/internal/crypto/cfrg.js
@@ -301,12 +301,24 @@ async function cfrgImportKey(
301
name,
302
isPublic ? 'public' : 'private',
303
usagesSet);
304
- keyObject = createCFRGRawKey(
+
305
+ const publicKeyObject = createCFRGRawKey(
306
- Buffer.from(
307
- isPublic ? keyData.x : keyData.d,
308
- 'base64'),
309
- isPublic);
+ Buffer.from(keyData.x, 'base64'),
+ true);
310
+ if (isPublic) {
311
+ keyObject = publicKeyObject;
312
+ } else {
313
+ keyObject = createCFRGRawKey(
314
+ name,
315
+ Buffer.from(keyData.d, 'base64'),
316
+ false);
317
318
+ if (!createPublicKey(keyObject).equals(publicKeyObject)) {
319
+ throw lazyDOMException('Invalid JWK keyData', 'DataError');
320
+ }
321
322
break;
323
}
324
case 'raw': {
0 commit comments