From 181e378032757938be88d8a02d6f87be191b47e2 Mon Sep 17 00:00:00 2001 From: EduM22 <38257387+EduM22@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:58:56 +0200 Subject: fix(ext/crypto): check extractable in exportKey (#14222) --- cli/tests/unit/webcrypto_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index 94f011bae..63adaddc7 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -1750,3 +1750,23 @@ Deno.test(async function importJwkWithUse() { assert(key instanceof CryptoKey); }); + +// https://github.com/denoland/deno/issues/14215 +Deno.test(async function exportKeyNotExtractable() { + const key = await crypto.subtle.generateKey( + { + name: "HMAC", + hash: "SHA-512", + }, + false, + ["sign", "verify"], + ); + + assert(key); + assertEquals(key.extractable, false); + + await assertRejects(async () => { + // Should fail + await crypto.subtle.exportKey("raw", key); + }, DOMException); +}); -- cgit v1.2.3