(namedCurve)
| 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 | } |
no test coverage detected
searching dependent graphs…