test: Add test for HMAC key derivation
This commit is contained in:
parent
4746eb565d
commit
fecf3f61d5
|
@ -39,4 +39,22 @@ context("Crypto", () => {
|
||||||
["verify"]), core.CryptoError);
|
["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);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Reference in New Issue