diff --git a/test/crypto.ts b/test/crypto.ts index e5d51b0..246b496 100644 --- a/test/crypto.ts +++ b/test/crypto.ts @@ -39,4 +39,22 @@ context("Crypto", () => { ["verify"]), core.CryptoError); }); + it("HKDF derive HMAC key", async () => { + const hkdf = await crypto.subtle.importKey("raw", new Uint8Array([1, 2, 3, 4, 5]), { name: "HKDF" }, false, ["deriveKey"]); + const hmac = await crypto.subtle.deriveKey({ + name: "HKDF", + hash: "SHA-256", + info: new Uint8Array([1, 2, 3, 4, 5]), + salt: new Uint8Array([1, 2, 3, 4, 5]), + } as globalThis.HkdfParams, + hkdf, + { + name: "HMAC", + hash: "SHA-1", + } as globalThis.HmacImportParams, + false, + ["sign"]); + assert.strictEqual((hmac.algorithm as globalThis.HmacKeyAlgorithm).length, 512); + }); + });