summaryrefslogtreecommitdiff
path: root/cli/tests/unit/webcrypto_test.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2021-09-16 12:42:38 +0530
committerGitHub <noreply@github.com>2021-09-16 09:12:38 +0200
commit9270cad67cffefa4c7ced8361580834d92a00732 (patch)
treec46cf2b4357805af1d98347e2e523cb5560cd8f3 /cli/tests/unit/webcrypto_test.ts
parent3c97dbf06bc26fc79f0f58a360ef821f75ba82e9 (diff)
fix(ext/crypto): don't use core.decode for encoding jwk keys (#12088)
Diffstat (limited to 'cli/tests/unit/webcrypto_test.ts')
-rw-r--r--cli/tests/unit/webcrypto_test.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts
index 2dda71e6f..7a2bed758 100644
--- a/cli/tests/unit/webcrypto_test.ts
+++ b/cli/tests/unit/webcrypto_test.ts
@@ -357,6 +357,30 @@ unitTest(async function subtleCryptoHmacImportExport() {
assertEquals(exportedKey2, jwk);
});
+// https://github.com/denoland/deno/issues/12085
+unitTest(async function generateImportHmacJwk() {
+ const key = await crypto.subtle.generateKey(
+ {
+ name: "HMAC",
+ hash: "SHA-512",
+ },
+ true,
+ ["sign"],
+ );
+ assert(key);
+ assertEquals(key.type, "secret");
+ assertEquals(key.extractable, true);
+ assertEquals(key.usages, ["sign"]);
+
+ const exportedKey = await crypto.subtle.exportKey("jwk", key);
+ assertEquals(exportedKey.kty, "oct");
+ assertEquals(exportedKey.alg, "HS512");
+ assertEquals(exportedKey.key_ops, ["sign"]);
+ assertEquals(exportedKey.ext, true);
+ assert(typeof exportedKey.k == "string");
+ assertEquals(exportedKey.k.length, 171);
+});
+
// 2048-bits publicExponent=65537
const pkcs8TestVectors = [
// rsaEncryption