mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
Fixes: https://github.com/nodejs/node/issues/59534 PR-URL: https://github.com/nodejs/node/pull/59538 Fixes: https://github.com/nodejs/node/issues/59535 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
22 lines
831 B
JavaScript
22 lines
831 B
JavaScript
import * as common from '../common/index.mjs';
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
import * as assert from 'node:assert';
|
|
import * as util from 'node:util';
|
|
|
|
const { subtle } = globalThis.crypto;
|
|
|
|
const kp = await subtle.generateKey('Ed25519', true, ['sign', 'verify']);
|
|
assert.notStrictEqual(kp.publicKey.algorithm, kp.privateKey.algorithm);
|
|
assert.notStrictEqual(kp.publicKey.usages, kp.privateKey.usages);
|
|
kp.publicKey.algorithm.name = 'ed25519';
|
|
assert.strictEqual(kp.publicKey.algorithm.name, 'ed25519');
|
|
kp.publicKey.usages.push('foo');
|
|
assert.ok(kp.publicKey.usages.includes('foo'));
|
|
assert.ok(util.inspect(kp.publicKey).includes("algorithm: { name: 'Ed25519' }"));
|
|
assert.ok(util.inspect(kp.publicKey).includes("usages: [ 'verify' ]"));
|
|
|
|
await subtle.sign('Ed25519', kp.privateKey, Buffer.alloc(32));
|