| Index: LayoutTests/crypto/sign-verify-badParameters.html
|
| diff --git a/LayoutTests/crypto/sign-verify-badParameters.html b/LayoutTests/crypto/sign-verify-badParameters.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..707c7eb0d3bdb2c22bf5b56c06dc1e048fc2db28
|
| --- /dev/null
|
| +++ b/LayoutTests/crypto/sign-verify-badParameters.html
|
| @@ -0,0 +1,54 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<head>
|
| +<script src="../resources/js-test.js"></script>
|
| +<script src="resources/common.js"></script>
|
| +</head>
|
| +<body>
|
| +<p id="description"></p>
|
| +<div id="console"></div>
|
| +
|
| +<script>
|
| +description("Tests calling cypto.subtle.sign and crypto.subtle.verify with incorrect inputs");
|
| +
|
| +jsTestIsAsync = true;
|
| +
|
| +function importHmacKey()
|
| +{
|
| + var importAlgorithm = {name: 'HMAC', hash: {name: 'sha-1'}};
|
| + var keyData = new Uint8Array(16);
|
| + var extractable = true;
|
| + var usages = ['sign', 'verify'];
|
| +
|
| + return crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable, usages);
|
| +}
|
| +
|
| +data = asciiToUint8Array("hello");
|
| +hmac = {name: 'HMAC', hash: {name: 'sha-1'}};
|
| +
|
| +importHmacKey().then(function(result) {
|
| + key = result;
|
| +
|
| + // Pass invalid signature parameters to verify()
|
| + shouldThrow("crypto.subtle.verify(hmac, key, null, data)");
|
| + shouldThrow("crypto.subtle.verify(hmac, key, 'a', data)");
|
| + shouldThrow("crypto.subtle.verify(hmac, key, [], data)");
|
| +
|
| + // Operation does not support signing.
|
| + return crypto.subtle.sign({name: 'sha-1'}, key, data);
|
| +}).then(failAndFinishJSTest, function(result) {
|
| + error = result;
|
| + shouldBeNull("error");
|
| +
|
| + // Operation doesn't support signing (also given an invalid key, but the
|
| + // first failure takes priority)
|
| + return crypto.subtle.sign({name: 'RSAES-PKCS1-v1_5'}, key, data);
|
| +}).then(failAndFinishJSTest, function(result) {
|
| + error = result;
|
| + shouldBeNull("error");
|
| +}).then(finishJSTest, failAndFinishJSTest);
|
| +
|
| +</script>
|
| +
|
| +</body>
|
| +</html>
|
|
|