48 lines
1.3 KiB
HTML
48 lines
1.3 KiB
HTML
<!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 verification with malformed parameters");
|
|
|
|
jsTestIsAsync = true;
|
|
|
|
var extractable = false;
|
|
var text = asciiToUint8Array("Hello, World!");
|
|
var signature = hexStringToUint8Array("6e8e66ff128606f52b8c589196ef5e0f7ca04816");
|
|
var hmacImportParams = {
|
|
name: "hmac",
|
|
hash: "sha-1",
|
|
}
|
|
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
|
|
|
|
// Not enough arguments.
|
|
shouldReject('crypto.subtle.verify()');
|
|
shouldReject('crypto.subtle.verify(1)');
|
|
shouldReject('crypto.subtle.verify(1, 2)');
|
|
shouldReject('crypto.subtle.verify(1, 2, 3)');
|
|
|
|
crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(result) {
|
|
wrongKey = result;
|
|
// Wrong algorithm identifier.
|
|
shouldReject('crypto.subtle.verify("rsassa-pkcs1-v1_5", wrongKey, signature, text)');
|
|
|
|
return crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign"]);
|
|
}).then(function(result) {
|
|
wrongKey = result;
|
|
// Wrong usage.
|
|
return shouldReject('crypto.subtle.verify("hmac", wrongKey, signature, text)');
|
|
}).then(finishJSTest);
|
|
|
|
</script>
|
|
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|