summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2021-10-08 20:59:36 +0530
committerGitHub <noreply@github.com>2021-10-08 17:29:36 +0200
commita5d3c8b06cba652b902fdfaa3f13ed40483e90c0 (patch)
tree967413a9cdab742cbc7a500006859ac938b79d53 /cli/tests
parentc49a057599d68b27c88cc123a9fcd6703b49310c (diff)
feat(ext/crypto): implement deriveBits for ECDH (p256) (#11873)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/webcrypto_test.ts25
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(