MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-webcrypto-keygen-kmac.js:19–40  ·  view source on GitHub ↗
(name, length)

Source from the content-addressed store, hash-verified

17const usages = ['sign', 'verify'];
18
19async function test(name, length) {
20 length ??= name === 'KMAC128' ? 128 : 256;
21 const key = await subtle.generateKey({
22 name,
23 length,
24 }, true, usages);
25
26 assert(key);
27 assert(isCryptoKey(key));
28
29 assert.strictEqual(key.type, 'secret');
30 assert.strictEqual(key.toString(), '[object CryptoKey]');
31 assert.strictEqual(key.extractable, true);
32 assert.deepStrictEqual(key.usages, usages);
33 assert.strictEqual(key.algorithm.name, name);
34 assert.strictEqual(key.algorithm.length, length);
35 assert.strictEqual(key.algorithm, key.algorithm);
36 assert.strictEqual(key.usages, key.usages);
37
38 const raw = await subtle.exportKey('raw-secret', key);
39 assert.strictEqual(raw.byteLength, Math.ceil(length / 8));
40}
41
42const kTests = [
43 ['KMAC128', 0],

Callers 1

Calls 3

isCryptoKeyFunction · 0.85
assertFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…