jiewen_tan@apple.com | df5276a | 2016-11-10 18:36:44 +0000 | [diff] [blame] | 1 | <!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> |
| 12 | description("Test importing a JWK RSAES-PKCS1-v1_5 public key with leading zero"); |
| 13 | |
| 14 | jsTestIsAsync = true; |
| 15 | |
| 16 | var jwkKey = { |
| 17 | kty: "RSA", |
| 18 | n: "AGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2g", |
| 19 | e: "AQAB" |
| 20 | }; |
| 21 | var extractable = true; |
| 22 | |
| 23 | debug("Importing a key..."); |
| 24 | crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]).then(function(result) { |
| 25 | publicKey = result; |
| 26 | |
| 27 | shouldBe("publicKey.type", "'public'"); |
| 28 | shouldBe("publicKey.extractable", "true"); |
| 29 | shouldBe("publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'"); |
| 30 | shouldBe("publicKey.algorithm.modulusLength", "2048"); |
| 31 | shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'"); |
| 32 | shouldBeUndefined("publicKey.algorithm.hash"); |
| 33 | shouldBe("publicKey.usages", "['encrypt']"); |
| 34 | |
| 35 | finishJSTest(); |
| 36 | }); |
| 37 | |
| 38 | </script> |
| 39 | |
| 40 | <script src="../../resources/js-test-post.js"></script> |
| 41 | </body> |
| 42 | </html> |