jiewen_tan@apple.com | 8a7dc9c | 2017-03-08 02:09:38 +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 ECDH public key with P-384"); |
| 13 | |
| 14 | jsTestIsAsync = true; |
| 15 | |
| 16 | var jwkKey = { |
| 17 | kty: "EC", |
| 18 | use: "enc", |
| 19 | ext: true, |
| 20 | crv: "P-384", |
| 21 | x: "1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK", |
| 22 | y: "1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK", |
| 23 | }; |
| 24 | var extractable = true; |
| 25 | |
| 26 | debug("Importing a key..."); |
| 27 | crypto.subtle.importKey("jwk", jwkKey, { name: "ECDH", namedCurve: "P-384" }, extractable, [ ]).then(function(result) { |
| 28 | publicKey = result; |
| 29 | |
| 30 | shouldBe("publicKey.toString()", "'[object CryptoKey]'"); |
| 31 | shouldBe("publicKey.type", "'public'"); |
| 32 | shouldBe("publicKey.extractable", "true"); |
| 33 | shouldBe("publicKey.algorithm.name", "'ECDH'"); |
| 34 | shouldBe("publicKey.algorithm.namedCurve", "'P-384'"); |
| 35 | shouldBe("publicKey.usages", "[ ]"); |
| 36 | |
| 37 | finishJSTest(); |
| 38 | }); |
| 39 | |
| 40 | </script> |
| 41 | |
| 42 | <script src="../../resources/js-test-post.js"></script> |
| 43 | </body> |
| 44 | </html> |