blob: 1a49c3254e1dd0b56be2998e2638d0a9457b2ed0 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test generating an HMAC key with malformed-paramters.");
var extractable = true;
// Malformed AlgorithmIdentifiers
shouldReject('crypto.subtle.generateKey("hmac", extractable, ["sign", "verify"])');
shouldReject('crypto.subtle.generateKey({name: "hmac"}, extractable, ["sign", "verify"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: null}, extractable, ["sign", "verify"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: Symbol()}, extractable, ["sign", "verify"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: { }}, extractable, ["sign", "verify"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: "foo"}, extractable, ["sign", "verify"])');
// Wrong usages
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["encrypt"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["decrypt"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["deriveKey"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["deriveBits"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["wrapKey"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["unwrapKey"])');
// Wrong length
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: 0}, extractable, ["sign", "verify"])');
shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: 5}, extractable, ["sign", "verify"])');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>