4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"resources/common.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
12 description("Test exporting a public EC key.");
16 var extractable
= true;
18 var publicKeySpkiHex
= "3059301306072A8648CE3D020106082A8648CE3D030107034200049CB0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78";
20 debug("\nImporting a SPKI key...");
21 crypto
.subtle
.importKey("spki", hexStringToUint8Array(publicKeySpkiHex
), {name
: "ECDSA", namedCurve
: "P-256"}, extractable
, ['verify']).then(function(result
) {
24 debug("\nExporting the key as JWK...");
25 return crypto
.subtle
.exportKey("jwk", key
);
26 }).then(function(result
) {
29 shouldEvaluateAs("exportedJWK.kty", "EC");
30 shouldEvaluateAs("exportedJWK.crv", "P-256");
31 shouldEvaluateAs("exportedJWK.x", "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc");
32 shouldEvaluateAs("exportedJWK.y", "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg");
33 shouldBe("exportedJWK.alg", "undefined");
34 shouldBe("exportedJWK.ext", "true");
35 shouldBe("exportedJWK.key_ops", "['verify']");
36 shouldBe("exportedJWK.use", "undefined");
38 debug("\nExporting the key as SPKI...");
39 return crypto
.subtle
.exportKey("spki", key
);
40 }).then(function(result
) {
41 exportedSpki
= result
;
43 bytesShouldMatchHexString("exportedSpki", publicKeySpkiHex
, exportedSpki
);
44 }).then(finishJSTest
, failAndFinishJSTest
);