| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="../resources/common.js"></script> |
| </head> |
| <body> |
| <p id="description"></p> |
| <div id="console"></div> |
| |
| <script> |
| description("Test importing a jwk ECDH key and then export it in raw format"); |
| |
| jsTestIsAsync = true; |
| |
| var jwkKey = { |
| kty: "EC", |
| use: "enc", |
| ext: true, |
| crv: "P-256", |
| x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA", |
| y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI", |
| }; |
| var expectedRawKey = "04d454955a2793be2905906d4d3b286450268c6dd421c701fa682bb8133fac46d0f6398d4cba8ce1c8c185d0271dc348f58415dcef0b166a3e11d65693c9ed01a2"; |
| var extractable = true; |
| |
| debug("Importing a key..."); |
| crypto.subtle.importKey("jwk", jwkKey, { name: "ECDH", namedCurve: "P-256" }, extractable, [ ]).then(function(result) { |
| return crypto.subtle.exportKey("raw", result); |
| }).then(function(result) { |
| publicKey = result; |
| |
| shouldBe("bytesToHexString(publicKey)", "expectedRawKey"); |
| |
| finishJSTest(); |
| }); |
| |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |