47 lines
1.5 KiB
HTML
47 lines
1.5 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 what happens when trying to encrypt a too large plain text with RSA-OAEP.");
|
|
|
|
jsTestIsAsync = true;
|
|
|
|
var publicKeyJSON = {
|
|
kty: "RSA",
|
|
alg: "RSA-OAEP",
|
|
n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
|
|
e: "AQAB"
|
|
};
|
|
|
|
var extractable = true;
|
|
|
|
debug("Importing RSA keys...");
|
|
crypto.subtle.importKey("jwk", publicKeyJSON, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt"]).then(function(result) {
|
|
publicKey = result;
|
|
|
|
debug("Encrypting a 214 byte buffer with RSA-OAEP SHA-1, 2048 bit key...");
|
|
return crypto.subtle.encrypt("RSA-OAEP", publicKey, new Uint8Array(214));
|
|
}).then(function(result) {
|
|
testPassed("Succeeded");
|
|
debug("Encrypting a 215 byte buffer...");
|
|
return crypto.subtle.encrypt("RSA-OAEP", publicKey, new Uint8Array(215));
|
|
}).then(function(result) {
|
|
testFailed("Succeeded");
|
|
finishJSTest();
|
|
}, function(result) {
|
|
testPassed("Rejected");
|
|
finishJSTest();
|
|
});
|
|
</script>
|
|
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|