# script to generate the generateKey tests
import os
here = os.path.dirname(__file__)
successes_html = """
WebCryptoAPI: generateKey() Successful Calls
generateKey Tests for Good Parameters
Warning! RSA key generation is intrinsically
very slow, so the related tests can take up to
several minutes to complete, depending on browser!
"""
failures_html = """
WebCryptoAPI: generateKey() for Failures
generateKey Tests for Bad Parameters
"""
successes_worker = """// META: timeout=long
importScripts("/resources/testharness.js");
importScripts("../util/helpers.js");
importScripts("successes.js");
run_test([%s]);
done();"""
failures_worker = """// META: timeout=long
importScripts("/resources/testharness.js");
importScripts("../util/helpers.js");
importScripts("failures.js");
run_test([%s]);
done();"""
names = ["AES-CTR", "AES-CBC", "AES-GCM", "AES-KW", "HMAC", "RSASSA-PKCS1-v1_5",
"RSA-PSS", "RSA-OAEP", "ECDSA", "ECDH", "Ed25519", "Ed448", "X25519",
"X448"]
for filename_pattern, template in [("test_successes_%s.https.html", successes_html),
("test_failures_%s.https.html", failures_html),
("successes_%s.https.worker.js", successes_worker),
("failures_%s.https.worker.js", failures_worker)]:
for name in names:
path = os.path.join(here, os.pardir, "generateKey", filename_pattern % name)
with open(path, "w") as f:
f.write(template % '"%s"' % name)