Update SubtleCrypto::generateKey to match the latest spec
[WebKit-https.git] / LayoutTests / crypto / workers / subtle / resources / hmac-generate-key.js
1 importScripts('../../../../resources/js-test-pre.js');
2
3 description("Test generating an HMAC key using SHA-1 algorithm in workers.");
4 jsTestIsAsync = true;
5
6 var extractable = true;
7
8 shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["encrypt"])');
9 shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: 0}, extractable, ["sign", "verify"])');
10
11 debug("Generating a key...");
12 crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(result) {
13     key = result;
14
15     shouldBe("key.type", "'secret'");
16     shouldBe("key.extractable", "true");
17     shouldBe("key.algorithm.name", "'HMAC'");
18     shouldBe("key.algorithm.length", "512");
19     shouldBe("key.algorithm.hash.name", "'SHA-1'");
20     shouldBe("key.usages", '["sign", "verify"]');
21
22     finishJSTest();
23 });