crypto: fix private SPKI export error · nodejs/node@b6d7ed3 · GitHub
Skip to content

Commit b6d7ed3

Browse files
panvaaduh95
authored andcommitted
crypto: fix private SPKI export error
Reject SPKI export of a private asymmetric key with InvalidAccessError as required by the algorithm export steps. Let wrapKey propagate the same export failure. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #65550 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 847fe4d commit b6d7ed3

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

‎lib/internal/crypto/webcrypto.js‎

Lines changed: 17 additions & 13 deletions

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ async function testImportPkcs8(
162162
assert.strictEqual(
163163
Buffer.from(pkcs8).toString('hex'),
164164
keyData[namedCurve].pkcs8.toString('hex'));
165+
166+
await assert.rejects(
167+
subtle.exportKey('spki', key), {
168+
message: 'Key must be a public key',
169+
name: 'InvalidAccessError',
170+
});
165171
} else {
166172
await assert.rejects(
167173
subtle.exportKey('pkcs8', key), {

‎test/parallel/test-webcrypto-wrap-unwrap.js‎

Lines changed: 4 additions & 4 deletions

0 commit comments

Comments
 (0)