| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../resources/js-test.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 exporting a public EC key."); | |
| 13 | |
| 14 jsTestIsAsync = true; | |
| 15 | |
| 16 var extractable = true; | |
| 17 | |
| 18 var publicKeySpkiHex = "3059301306072A8648CE3D020106082A8648CE3D030107034200049C
B0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86
EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78"; | |
| 19 | |
| 20 debug("\nImporting a SPKI key..."); | |
| 21 crypto.subtle.importKey("spki", hexStringToUint8Array(publicKeySpkiHex), {name:
"ECDSA", namedCurve: "P-256"}, extractable, ['verify']).then(function(result) { | |
| 22 key = result; | |
| 23 | |
| 24 debug("\nExporting the key as JWK..."); | |
| 25 return crypto.subtle.exportKey("jwk", key); | |
| 26 }).then(function(result) { | |
| 27 exportedJWK = result; | |
| 28 | |
| 29 shouldEvaluateAs("exportedJWK.kty", "EC"); | |
| 30 shouldEvaluateAs("exportedJWK.crv", "P-256"); | |
| 31 shouldEvaluateAs("exportedJWK.x", "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1
vc"); | |
| 32 shouldEvaluateAs("exportedJWK.y", "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6H
Hg"); | |
| 33 shouldBe("exportedJWK.alg", "undefined"); | |
| 34 shouldBe("exportedJWK.ext", "true"); | |
| 35 shouldBe("exportedJWK.key_ops", "['verify']"); | |
| 36 shouldBe("exportedJWK.use", "undefined"); | |
| 37 | |
| 38 debug("\nExporting the key as SPKI..."); | |
| 39 return crypto.subtle.exportKey("spki", key); | |
| 40 }).then(function(result) { | |
| 41 exportedSpki = result; | |
| 42 | |
| 43 bytesShouldMatchHexString("exportedSpki", publicKeySpkiHex, exportedSpki); | |
| 44 }).then(finishJSTest, failAndFinishJSTest); | |
| 45 | |
| 46 </script> | |
| 47 | |
| 48 </body> | |
| 49 </html> | |
| OLD | NEW |