diff options
Diffstat (limited to 'cli/tests/unit/webcrypto_test.ts')
-rw-r--r-- | cli/tests/unit/webcrypto_test.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index b38a9934f..80275b002 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -513,6 +513,31 @@ unitTest(async function testHkdfDeriveBits() { assertEquals(result.byteLength, 128 / 8); }); +// TODO(@littledivy): Enable WPT when we have importKey support +unitTest(async function testECDH() { + const namedCurve = "P-256"; + const keyPair = await crypto.subtle.generateKey( + { + name: "ECDH", + namedCurve, + }, + true, + ["deriveBits"], + ); + + const derivedKey = await crypto.subtle.deriveBits( + { + name: "ECDH", + public: keyPair.publicKey, + }, + keyPair.privateKey, + 256, + ); + + assert(derivedKey instanceof ArrayBuffer); + assertEquals(derivedKey.byteLength, 256 / 8); +}); + unitTest(async function testWrapKey() { // Test wrapKey const key = await crypto.subtle.generateKey( |