[WebCrypto] Crypto operations should copy their parameters before hoping to another...
[WebKit-https.git] / LayoutTests / http / wpt / crypto / rsa-oaep-crash.any.js
1 // META: script=./resources/common.js
2
3 test(() => {
4     const max = 10000;
5     const plainText = asciiToUint8Array("Hello, World!");
6     const jwkKey = {
7         kty: "RSA",
8         alg: "RSA-OAEP",
9         use: "enc",
10         key_ops: ["encrypt", "wrapKey"],
11         ext: true,
12         n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
13         e: "AQAB"
14     };
15     const rsaOaepParams = {
16         name: "rsa-oaep"
17     };
18     crypto.subtle.importKey('jwk', jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, false, ["encrypt"]).then(key => {
19         for (let i = 0; i < max; i++)
20             crypto.subtle.encrypt(rsaOaepParams, key, plainText);
21     });
22 }, "Test passed if no crashes.");