summaryrefslogtreecommitdiff
path: root/cli/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit')
-rw-r--r--cli/tests/unit/webcrypto_test.ts48
1 files changed, 22 insertions, 26 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts
index ea2c05781..a6cab93dd 100644
--- a/cli/tests/unit/webcrypto_test.ts
+++ b/cli/tests/unit/webcrypto_test.ts
@@ -716,27 +716,28 @@ Deno.test(async function testAesCtrEncryptDecrypt() {
});
Deno.test(async function testECDH() {
- const namedCurve = "P-256";
- const keyPair = await crypto.subtle.generateKey(
- {
- name: "ECDH",
- namedCurve,
- },
- true,
- ["deriveBits"],
- );
+ for (const keySize of [256, 384]) {
+ const keyPair = await crypto.subtle.generateKey(
+ {
+ name: "ECDH",
+ namedCurve: "P-" + keySize,
+ },
+ true,
+ ["deriveBits"],
+ );
- const derivedKey = await crypto.subtle.deriveBits(
- {
- name: "ECDH",
- public: keyPair.publicKey,
- },
- keyPair.privateKey,
- 256,
- );
+ const derivedKey = await crypto.subtle.deriveBits(
+ {
+ name: "ECDH",
+ public: keyPair.publicKey,
+ },
+ keyPair.privateKey,
+ keySize,
+ );
- assert(derivedKey instanceof ArrayBuffer);
- assertEquals(derivedKey.byteLength, 256 / 8);
+ assert(derivedKey instanceof ArrayBuffer);
+ assertEquals(derivedKey.byteLength, keySize / 8);
+ }
});
Deno.test(async function testWrapKey() {
@@ -1299,22 +1300,17 @@ Deno.test(async function testImportEcDhJwk() {
);
assert(equalJwk(publicJWK, expPublicKeyJWK as JWK));
- // deriveBits still not implemented for P384
- if (size != 256) {
- continue;
- }
-
const derivedKey = await subtle.deriveBits(
{
name: "ECDH",
public: publicKeyECDH,
},
privateKeyECDH,
- 256,
+ size,
);
assert(derivedKey instanceof ArrayBuffer);
- assertEquals(derivedKey.byteLength, 256 / 8);
+ assertEquals(derivedKey.byteLength, size / 8);
}
});