mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
crypto: forbid NODE-ED25519 and NODE-ED448 "raw" key export
closes #38655 PR-URL: https://github.com/nodejs/node/pull/38668 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
a028805f1b
commit
36bb8daba5
2 files changed
+11
-11
No files matched your search
@@ -288,8 +288,11 @@ async function exportKeyRaw(key) {
|
||||
case 'NODE-ED25519':
|
||||
// Fall through
|
||||
case 'NODE-ED448':
|
||||
return lazyRequire('internal/crypto/ec')
|
||||
.ecExportKey(key, kWebCryptoKeyFormatRaw);
|
||||
if (key.type === 'public') {
|
||||
return lazyRequire('internal/crypto/ec')
|
||||
.ecExportKey(key, kWebCryptoKeyFormatRaw);
|
||||
}
|
||||
break;
|
||||
case 'ECDSA':
|
||||
// Fall through
|
||||
case 'ECDH':
|
||||
|
||||
@@ -268,15 +268,12 @@ async function test2(namedCurve) {
|
||||
true, ['verify']),
|
||||
]);
|
||||
|
||||
const [
|
||||
rawKey1,
|
||||
rawKey2,
|
||||
] = await Promise.all([
|
||||
subtle.exportKey('raw', privateKey),
|
||||
subtle.exportKey('raw', publicKey),
|
||||
]);
|
||||
assert.deepStrictEqual(Buffer.from(rawKey1), vector.privateKey);
|
||||
assert.deepStrictEqual(Buffer.from(rawKey2), vector.publicKey);
|
||||
const rawPublicKey = await subtle.exportKey('raw', publicKey);
|
||||
assert.deepStrictEqual(Buffer.from(rawPublicKey), vector.publicKey);
|
||||
|
||||
assert.rejects(subtle.exportKey('raw', privateKey), {
|
||||
message: new RegExp(`Unable to export a raw ${namedCurve} private key`)
|
||||
}).then(common.mustCall());
|
||||
|
||||
const sig = await subtle.sign(
|
||||
{ name: namedCurve },
|
||||
|
||||
Reference in new issue
Block a user