diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-08-13 14:57:56 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-13 11:27:56 +0200 |
commit | c1f97056f42d20158d469d023652f3b338411007 (patch) | |
tree | 0084cd8bee096c97b057e40f70a6b0fa27a8a3ac /cli | |
parent | 848137750005e27c7afb0794a51751db3ab5e5fa (diff) |
fix(ext/crypto): take a copy of keyData bytes (#11666)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/tests/unit/webcrypto_test.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index 4af31789a..988cd61f6 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -1,5 +1,26 @@ import { assert, assertEquals, unitTest } from "./test_util.ts"; +// https://github.com/denoland/deno/issues/11664 +unitTest(async function testImportArrayBufferKey() { + const subtle = window.crypto.subtle; + assert(subtle); + + // deno-fmt-ignore + const key = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + const cryptoKey = await subtle.importKey( + "raw", + key.buffer, + { name: "HMAC", hash: "SHA-1" }, + true, + ["sign"], + ); + assert(cryptoKey); + + // Test key usage + await subtle.sign({ name: "HMAC" }, cryptoKey, new Uint8Array(8)); +}); + // TODO(@littledivy): Remove this when we enable WPT for sign_verify unitTest(async function testSignVerify() { const subtle = window.crypto.subtle; |