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

Function test

test/parallel/test-webcrypto-derivekey.js:19–46  ·  view source on GitHub ↗
(namedCurve)

Source from the content-addressed store, hash-verified

17// Test ECDH key derivation
18{
19 async function test(namedCurve) {
20 const [alice, bob] = await Promise.all([
21 subtle.generateKey({ name: 'ECDH', namedCurve }, true, ['deriveKey']),
22 subtle.generateKey({ name: 'ECDH', namedCurve }, true, ['deriveKey']),
23 ]);
24
25 const [secret1, secret2] = await Promise.all([
26 subtle.deriveKey({
27 name: 'ECDH', namedCurve, public: alice.publicKey
28 }, bob.privateKey, {
29 name: 'AES-CBC',
30 length: 256
31 }, true, ['encrypt']),
32 subtle.deriveKey({
33 name: 'ECDH', namedCurve, public: bob.publicKey
34 }, alice.privateKey, {
35 name: 'AES-CBC',
36 length: 256
37 }, true, ['encrypt']),
38 ]);
39
40 const [raw1, raw2] = await Promise.all([
41 subtle.exportKey('raw', secret1),
42 subtle.exportKey('raw', secret2),
43 ]);
44
45 assert.deepStrictEqual(raw1, raw2);
46 }
47
48 test('P-521').then(common.mustCall());
49}

Callers 1

Calls 4

encodeMethod · 0.95
allMethod · 0.80
toStringMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…