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 private RSA key."); | |
13 | |
14 jsTestIsAsync = true; | |
15 | |
16 var extractable = true; | |
17 | |
18 var privateKeyPkcs8Hex = "3081B6020100301006072A8648CE3D020106052B8104002204819E
30819B0201010430A492CE8FA90084C227E1A32F7974D39E9FF67A7E8705EC3419B35FB607582BEB
D461E0B1520AC76EC2DD4E9B63EBAE71A16403620004E55FEE6C49D8D523F5CE7BF9C0425CE4FF65
0708B7DE5CFB095901523979A7F042602DB30854735369813B5C3F5EF86828F59CC5DC509892A988
D38A8E2519DE3D0C4FD0FBDB0993E38F18506C17606C5E24249246F1CE94983A5361C5BE983E"; | |
19 | |
20 debug("\nImporting a PKCS8 key..."); | |
21 crypto.subtle.importKey("pkcs8", hexStringToUint8Array(privateKeyPkcs8Hex), {nam
e: "ECDSA", namedCurve: "P-384" }, extractable, ['sign']).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-384"); | |
31 shouldEvaluateAs("exportedJWK.d", "pJLOj6kAhMIn4aMveXTTnp_2en6HBew0GbNftgdYK
-vUYeCxUgrHbsLdTptj665x"); | |
32 shouldEvaluateAs("exportedJWK.x", "5V_ubEnY1SP1znv5wEJc5P9lBwi33lz7CVkBUjl5p
_BCYC2zCFRzU2mBO1w_Xvho"); | |
33 shouldEvaluateAs("exportedJWK.y", "KPWcxdxQmJKpiNOKjiUZ3j0MT9D72wmT448YUGwXY
GxeJCSSRvHOlJg6U2HFvpg-"); | |
34 shouldBe("exportedJWK.alg", "undefined"); | |
35 shouldBe("exportedJWK.ext", "true"); | |
36 shouldBe("exportedJWK.key_ops", "['sign']"); | |
37 shouldBe("exportedJWK.use", "undefined"); | |
38 | |
39 debug("\nExporting the key as PKCS8..."); | |
40 return crypto.subtle.exportKey("pkcs8", key); | |
41 }).then(function(result) { | |
42 exportedPkcs8 = result; | |
43 | |
44 bytesShouldMatchHexString("exportedPkcs8", privateKeyPkcs8Hex, exportedPkcs8
); | |
45 }).then(finishJSTest, failAndFinishJSTest); | |
46 | |
47 </script> | |
48 | |
49 </body> | |
50 </html> | |
OLD | NEW |