blob: 587fa23fc4bc35413e33764686715daa30be5b45 [file] [log] [blame]
jiewen_tan@apple.comdf5276a2016-11-10 18:36:44 +00001<!DOCTYPE html>
2<html>
3<head>
4<script src="../../resources/js-test-pre.js"></script>
5<script src="../resources/common.js"></script>
6</head>
7<body>
8<p id="description"></p>
9<div id="console"></div>
10
11<script>
12description("Test importing a JWK RSA-OAEP public key with SHA-256");
13
14jsTestIsAsync = true;
15
16var jwkKey = {
17 kty: "RSA",
18 alg: "RSA-OAEP-256",
19 use: "enc",
20 key_ops: ["encrypt", "wrapKey"],
21 ext: true,
22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
23 e: "AQAB"
24};
25var extractable = true;
26
27debug("Importing a key...");
28crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-256"}, extractable, ["encrypt", "wrapKey"]).then(function(result) {
29 publicKey = result;
30
31 shouldBe("publicKey.toString()", "'[object CryptoKey]'");
32 shouldBe("publicKey.type", "'public'");
33 shouldBe("publicKey.extractable", "true");
34 shouldBe("publicKey.algorithm.name", "'RSA-OAEP'");
35 shouldBe("publicKey.algorithm.modulusLength", "2048");
36 shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
37 shouldBe("publicKey.algorithm.hash.name", "'SHA-256'");
38 shouldBe("publicKey.usages", "['encrypt', 'wrapKey']");
39
40 finishJSTest();
41});
42
43</script>
44
45<script src="../../resources/js-test-post.js"></script>
46</body>
47</html>