blob: a7df54b7ac372dc71faccff7c49a68a507368e04 [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 encrypting using RSA-OAEP with malformed parameters");
jsTestIsAsync = true;
var extractable = false;
var plainText = asciiToUint8Array("Hello, World!");
var jwkKey = {
kty: "RSA",
alg: "RSA-OAEP",
use: "enc",
key_ops: ["encrypt", "wrapKey"],
ext: true,
n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
e: "AQAB"
};
crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["encrypt"]).then(function(result) {
key = result;
// Malformed AlgorithmIdentifiers
shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: true}, key, plainText)');
shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: 1}, key, plainText)');
shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: null}, key, plainText)');
shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: Symbol()}, key, plainText)');
shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: { }}, key, plainText)');
shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: "foo"}, key, plainText)');
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>